Bottom line: Markdown is not LaTeX. It was designed for HTML instead of LaTeX.
(Yihui Xie Explaining Markdown, Pandoc, and LaTeX formatting power on SO )[https://stackoverflow.com/a/17648350/9115822]
git clone https://github.com/trendlock/picklerick.git
.Rnw.
file\
leads a function{}
brackets are used instead of ()
A simple form of a sweave
document is:
\documentclass{article}
\begin{document}
Text
\end{document}
In general sweave
will behave smartly with images, tables and plots. But there are commands to manually adjust the behaviour.
\clearpage
} - plush all material and start a new page\clearpage
} - allow to break the line here\newline
} - request a new line\newpage
} - request a new page\nolinebreak
} - no line break should happen here\nopagebreak
} - no page break should happen here\pagebreak
} - encourage page breakIe. the following will give two pages with the word Text on them
\documentclass{article}
\begin{document}
Text
\newpage
Text
\end{document}
\begin{document}
A font family is selected with :
\usepackage{<fontpkg>}
Then a certain block of text is assigned a font with the wrapper:
{\fontfamily{<fontcode>}\selectfont <text> }
\documentclass{article}
\usepackage{tgadventor}
\begin{document}
{\fontfamily{qag}\selectfont
This document is a sample document to test font
families and font typefaces.
}
\end{document}
Some examples to choose from:
tibble::tribble(
~Font, ~"fontpkg", ~"fontcode", ~Example,
"Computer Modern Roman", NA, "cmr", "Typeface-cmr.png",
"Latin Modern Roman", "lmodern", "lmr", "Typeface-lmr.png",
"Latin Modern Dunhill", "lmodern", "lmdh", "Typeface-lmdh.png",
"TEX Gyre Termes", "tgtermes", "qtm", "Typeface-qtm.png",
"TEX Gyre Pagella", "tgpagella", "qpl", "Typeface-qpl.png",
"TEX Gyre Bonum", "tgbonum", "qbk", "Typeface-qbk.png",
"TEX Gyre Schola", "tgschola", "qcs", "Typeface-qsc.png",
"Times", "times", "ptm", "Typeface-ptm.png",
"Utopia / Fourier", "utopia / fourier", "put", "Typeface-put.png",
"Palatino", "palatino", "ppl", "Typeface-ppl.png",
"Bookman", "bookman", "pbk", "Typeface-pbk.png",
"Charter", "charter", "bch", "Typeface-bch.png",
"Computer Modern Sans Serif", NA, "cmss", "Typeface-cmss.png",
"Latin Modern Sans Serif", "lmodern", "lmss", "Typeface-lmss.png",
"TEX Gyre Adventor", "tgadventor", "qag", "Typeface-qag.png",
"TEX Gyre Heros", "tgheros", "qhv", "Typeface-qhv.png",
"Helvetica", "helvet", "phv", "Typeface-phv.png",
"Computer Modern Typewriter", NA, "cmtt", "Typeface-cmtt.png",
"Latin Modern Sans Typewriter", "lmodern", "lmtt", "Typeface-lmtt.png",
"TEX Gyre Cursor", "tgcursor", "qcr", "Typeface-qcr.png",
"Courier", "courier", "pcr", "Typeface-pcr.png"
) %>% select(-Example) %>%
kableExtra::kable()
Font | fontpkg | fontcode |
---|---|---|
Computer Modern Roman | NA | cmr |
Latin Modern Roman | lmodern | lmr |
Latin Modern Dunhill | lmodern | lmdh |
TEX Gyre Termes | tgtermes | qtm |
TEX Gyre Pagella | tgpagella | qpl |
TEX Gyre Bonum | tgbonum | qbk |
TEX Gyre Schola | tgschola | qcs |
Times | times | ptm |
Utopia / Fourier | utopia / fourier | put |
Palatino | palatino | ppl |
Bookman | bookman | pbk |
Charter | charter | bch |
Computer Modern Sans Serif | NA | cmss |
Latin Modern Sans Serif | lmodern | lmss |
TEX Gyre Adventor | tgadventor | qag |
TEX Gyre Heros | tgheros | qhv |
Helvetica | helvet | phv |
Computer Modern Typewriter | NA | cmtt |
Latin Modern Sans Typewriter | lmodern | lmtt |
TEX Gyre Cursor | tgcursor | qcr |
Courier | courier | pcr |
Inserted after \begin{document}
:
\tableofcontents
This will build a table of contents for that numbers all \section{}
and \subsection{}
elements.
Adjust:
\usepackage[margin=0.8in]{geometry}
Footnotes can be inserted with the following function, and are self numbering:
\footnote{A footnote}
Now comes the fun… There are a few components to using a bibliography.
\begin{document}
Indicating a bib package to use. There are some arguments used here to specify the style of the citations and the sorting of the reference list. This particular combination was used for a report we did.
\usepackage[backend=bibtex, sorting=none, citestyle=authoryear]{biblatex}
Alternatively a author - year style would be another typical requirement: citestyle=authoryear
.
Documentation on sorting: biblatex 3.1.2
Secondly you must call a function to point to your bibliography file (.bib
) which must be in the same directory. In this example my file is called refs.bib
.
\bibliography{refs}
Insert the function at end of your document but before the \end{}
.
\printbibliography
In the .bib
file a reference might look like the following (the which can often be near the paper on google scholar if it is a academic paper, otherwise you will probably have to prepare them yourself):
@article{garland2005,
author={Bill Garland},
title = {Elementary Physics of Reactor Control Module - Fission Product Poisoning},
volume = {3},
url = {http://www.nuceng.ca/br_space/2017-09_4d03_6d03/misc_files/xenon_poisoning.pdf},
publisher = {Nuclear Engineering (Originally from McMaster University)},
year = {2005}
}
Try differnt options for numeric citations.
Tip: delete all the temp files in dir to clear bib settings.
\usepackage[backend=bibtex, sorting=none, citestyle=numeric]{biblatex}
Are included by default. To nullify the inclusion of page numbers use:
\pagenumbering{gobble}
Instead of the markdown usage of backticks and curly brackets, sweave
uses the following syntax to define a chunk:
<<chunkname>>=
print(mtcars)
@
<<setup, include=FALSE, cache=FALSE, echo=FALSE>>=
opts_chunk$set(echo=F)
library(<pkgs>)
@
<<cars, warning=FALSE, message=F>>=
ggplot(mtcars, aes(disp, mpg, col = as.factor(gear))) +
geom_point()
@
\begin{figure}
<<cars, warning=FALSE, message=F>>=
ggplot(mtcars, aes(disp, mpg, col = as.factor(gear))) +
geom_point()
@
\caption{The relationship between cylinder displacement and miles per gallon for each car.}
\label{fig:Cars}
\end{figure}
\begin{figure}
\includegraphics[width=\textwidth]{imgs/morty.jpg}
\caption{A caption about Morty}
\label{fig:morty}
\end{figure}
\usepackage{graphicx,caption}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=0.9\linewidth]{imgs/rick.png}
\caption{}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=0.9\linewidth]{imgs/morty.jpg}
\caption{}
\end{subfigure}
\caption{(a) Rick and (b) Morty}
\label{fig:rickmorty}
\end{figure}
Here is a sentence with reference to Figure \ref{fig:rickmorty}.
[h]
Place the float here, i.e., approximately at the same point it occurs in the source text (however, not exactly at the spot)[t]
Position at the top of the page.[b]
Position at the bottom of the page.[p]
Put on a special page for floats only.[H]
Places the float at precisely the location in the LaTeX code. Requires the float package (\usepackage{float}
).[Source][https://www.sharelatex.com/learn/Positioning_of_Figures]
\Sexpr{Sys.Date()}
(Stands for S
expression. S
being the precursor to R
)