latex
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| latex [2011/10/04 16:53] – skip | latex [2020/12/27 20:35] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ===== Latex ===== | ||
| + | ====Configuration==== | ||
| + | |||
| + | ===Installation=== | ||
| + | Unknown Errors are often caused by disabled automatic package installation. | ||
| + | They can be enabled through the Settings Menu, which is avaiable under: | ||
| + | |||
| + | * …MiKTeX x.x\miktex\bin\mo_admin.exe | ||
| + | * Start Menu-> | ||
| + | |||
| + | In the settings menu you should set **Install Missing Packages On-The-Fly -> YES** | ||
| + | |||
| + | {{ http:// | ||
| + | |||
| + | ====Usage==== | ||
| + | |||
| + | === Things to remember === | ||
| + | * When referencing an image write \caption before \label. r the \label or you will get **??** instead of a reference. < | ||
| + | \center | ||
| + | \includegraphics[width=0.3\textwidth]{images/ | ||
| + | \caption{Block groups} | ||
| + | \label{fig: | ||
| + | \end{wrapfigure}</ | ||
| + | * Use \clearpage and \cleardoublepage to start a new page. Theses commands really do begin a new page, drawing all pics before this command | ||
| + | |||
| + | |||
| + | === Reference === | ||
| + | |||
| + | * {{ http:// | ||
| + | * {{ http:// | ||
| + | * {{ http:// | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | === Scaling === | ||
| + | To scale something - put it into a box. | ||
| + | < | ||
| + | | ||
| + | </ | ||
| + | |||
| + | === Centering === | ||
| + | To center something - put it into a center environment | ||
| + | < | ||
| + | \begin{center} | ||
| + | to center | ||
| + | \end{center} | ||
| + | </ | ||
| + | |||
| + | |||
| + | === Define new commands === | ||
| + | Use commands like: ** \mydef{Definition}** | ||
| + | |||
| + | {{ http:// | ||
| + | |||
| + | < | ||
| + | % define new Definition command | ||
| + | \newcounter{mydefcount} | ||
| + | \newcommand{\mydef}[1]{ \stepcounter{mydefcount} | ||
| + | \colorbox{Orange} | ||
| + | {\large\textbf{Def \arabic{mydefcount}: | ||
| + | \newline\newline | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | === Temporary adjust text width=== | ||
| + | Outside of environments - wrap the text by // | ||
| + | < | ||
| + | % allows for temporary adjustment of side margins | ||
| + | \usepackage{chngpage} | ||
| + | \begin{adjustwidth}{-4cm}{-4cm} | ||
| + | ... | ||
| + | \end{adjustwidth} | ||
| + | </ | ||
| + | |||
| + | when using // | ||
| + | |||
| + | < | ||
| + | \begin{table}[h!b!p!] | ||
| + | %temporary change textwidth | ||
| + | \begin{adjustwidth}{-4cm}{-4cm}% adjust the L and R margins by 1 inch | ||
| + | \begin{tabular}{ *{2}{l} } | ||
| + | |||
| + | CellOne | ||
| + | CellThree & CellFour \\ | ||
| + | |||
| + | \end{tabular} | ||
| + | |||
| + | \end{adjustwidth} | ||
| + | \end{table} | ||
| + | </ | ||
| + | |||
| + | |||
| + | === Table === | ||
| + | Table contains of two environments //table// and // | ||
| + | Here a table, which is wider, than the textwidth. | ||
| + | |||
| + | < | ||
| + | \begin{table}[h!b!p!] | ||
| + | %temporary change textwidth | ||
| + | \begin{adjustwidth}{-4cm}{-4cm}% adjust the L and R margins by 1 inch | ||
| + | |||
| + | %odd-even row coloring | ||
| + | \rowcolors{2}{gray!10}{} | ||
| + | |||
| + | %centering the table | ||
| + | \begin{center} | ||
| + | %scaling the table | ||
| + | \scalebox{0.8}{ | ||
| + | %tabular is INSIDE of all environments, | ||
| + | \begin{tabular}{ *{2}{l} } | ||
| + | |||
| + | CellOne | ||
| + | CellThree & CellFour \\ | ||
| + | |||
| + | \end{tabular} | ||
| + | } | ||
| + | \end{center} | ||
| + | |||
| + | \caption{Software key size related papers } | ||
| + | \label{tab: | ||
| + | |||
| + | \end{adjustwidth} | ||
| + | \end{table} | ||
| + | </ | ||
| + | |||
| + | As a second example a table, with a linebreak in one of the cells using **parbox** | ||
| + | < | ||
| + | \begin{table}[!h] | ||
| + | |||
| + | %odd-even row coloring | ||
| + | \rowcolors{2}{gray!10}{} | ||
| + | |||
| + | %centering the table | ||
| + | \begin{center} | ||
| + | %scaling the table | ||
| + | \scalebox{0.70}{ | ||
| + | %tabular is INSIDE of all environments, | ||
| + | \begin{tabular}{ l p{3cm} p{4cm} l l l } | ||
| + | |||
| + | \multicolumn{1}{c}{Year} & | ||
| + | \multicolumn{1}{c}{Task} & | ||
| + | \hline | ||
| + | 1990 & \parbox[t]{4cm}{First line \\ second} \\ | ||
| + | 1991 & \parbox[t]{4cm}{Again a line \\ second} \\ | ||
| + | |||
| + | \end{tabular} | ||
| + | } | ||
| + | \end{center} | ||
| + | |||
| + | \caption{Software key size related papers } | ||
| + | \label{tab: | ||
| + | |||
| + | \end{table} | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===Footmarks=== | ||
| + | Footmarks are easily possible in Latex. \footnotemark[1] creates a footmark. \footnotetext[1]{text} creates a footmark text. | ||
| + | |||
| + | < | ||
| + | \footnotemark \footnotetext{text} | ||
| + | </ | ||
| + | |||
| + | ===Margin notes=== | ||
| + | Use package // | ||
| + | < | ||
| + | \usepackage{marginnote} | ||
| + | \newcommand{\mnote}[1]{\marginnote{\color{LightBlue}# | ||
| + | \mnote{Programming Block Type} | ||
| + | </ | ||
| + | {{http:// | ||
| + | |||
| + | |||
| + | === Site geometry === | ||
| + | Use package // | ||
| + | < | ||
| + | \usepackage{geometry} | ||
| + | \newgeometry{top=0in, | ||
| + | \pagestyle{empty} %hides all titles and page numbers | ||
| + | \fancyheadoffset[LO, | ||
| + | \fancyfootoffset[RE]{0in} | ||
| + | |||
| + | %do something e.g. draw a picture | ||
| + | \begin{figure}[htb] | ||
| + | \center{\includegraphics[height=28cm] | ||
| + | {images/ | ||
| + | \end{figure} | ||
| + | |||
| + | \restoregeometry | ||
| + | </ | ||
| + | |||
| + | === Hyperlinks === | ||
| + | Hyperlinks are imported by the package // | ||
| + | Internal links can be created by referencing a figure, section, table, bibtexentry etc. | ||
| + | < | ||
| + | \label{name} | ||
| + | \pageref{fig: | ||
| + | \ref{bibkey} | ||
| + | |||
| + | |||
| + | %define a command with a counter and 2 parameters and build in label to be passed as a parameter | ||
| + | \newcounter{mydefcount} % define new counter | ||
| + | \newcommand{\mydef}[2]{ \stepcounter{mydefcount} | ||
| + | \colorbox{red} | ||
| + | {\large\textbf{\label{# | ||
| + | \newline\newline | ||
| + | } | ||
| + | |||
| + | %use the command | ||
| + | \mydef{Definition text}{labelname} | ||
| + | |||
| + | %reference the definition | ||
| + | \ref{labelname} | ||
| + | \pageref{labelname} | ||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | or internal links can be created by introducing an anchor: | ||
| + | < | ||
| + | \hypertarget{name}{text} | ||
| + | \hyperlink{< | ||
| + | </ | ||
| + | |||
| + | external links are created as | ||
| + | < | ||
| + | \href{http:// | ||
| + | </ | ||
| + | |||
| + | ===Minipages=== | ||
| + | To align text and a picture side by side use minipages. | ||
| + | |||
| + | < | ||
| + | % Subclasses of ShapeWithSlotsHead | ||
| + | \begin{figure}[ht] | ||
| + | \begin{minipage}[b]{0.5\linewidth} | ||
| + | Text here | ||
| + | \end{minipage} | ||
| + | \hspace{0.5cm} | ||
| + | \begin{minipage}[b]{0.5\linewidth} | ||
| + | \centering | ||
| + | \includegraphics[scale=1]{picture.png} | ||
| + | \caption{default} | ||
| + | \label{fig: | ||
| + | \end{minipage} | ||
| + | \end{figure} | ||
| + | </ | ||
| + | |||
| + | ===Citation=== | ||
| + | The package biblatex is required for citation. It can be loaded with a bunch of options. [[ftp:// | ||
| + | Authoryear and abbreviate make citations look like **Knuth et al., 2009**. | ||
| + | < | ||
| + | | ||
| + | bibstyle=authoryear, | ||
| + | citestyle=authoryear, | ||
| + | natbib=true, | ||
| + | hyperref=true, | ||
| + | backref=false, | ||
| + | abbreviate=true]{biblatex} | ||
| + | </ | ||
| + | |||
| + | Citations is text can be dona with the commands. I prefer **\parencite** for citations to be displayed as **[Knuth et al., 2009]** | ||
| + | < | ||
| + | \citet = in-text citation, as in: Morgan & Keenan (1973) | ||
| + | \citep{< | ||
| + | \nocite{< | ||
| + | \parencite | ||
| + | \parencite* = the star makes all authors to be listed as [Morgan, | ||
| + | </ | ||
| + | |||
| + | Unfortunately biblatex links only the year, not the whole entry. For the whole entry to be a link to look like that: | ||
| + | {{ http:// | ||
| + | < | ||
| + | \makeatletter | ||
| + | %Works without the last bracket ;-) | ||
| + | \let\abx@macro@citeOrig\abx@macro@cite | ||
| + | \renewbibmacro{cite}{% | ||
| + | | ||
| + | | ||
| + | | ||
| + | }% | ||
| + | } | ||
| + | \let\abx@macro@textciteOrig\abx@macro@textcite | ||
| + | \renewbibmacro{textcite}{% | ||
| + | | ||
| + | | ||
| + | | ||
| + | }% | ||
| + | }% | ||
| + | \makeatother | ||
| + | </ | ||
| + | |||
| + | At least the literature references are printed with the command **\printbibliography**. | ||
| + | To easily find the referenced literature it should start with the abbreviation in parentheses, | ||
| + | {{ http:// | ||
| + | For that use the following snippet: | ||
| + | < | ||
| + | \newcounter{mymaxcitenames} | ||
| + | \AtBeginDocument{% | ||
| + | \setcounter{mymaxcitenames}{\value{maxnames}}% | ||
| + | } | ||
| + | |||
| + | \renewbibmacro*{begentry}{% | ||
| + | \printtext[brackets]{% | ||
| + | \begingroup | ||
| + | \defcounter{maxnames}{\value{mymaxcitenames}}% | ||
| + | \printnames{labelname}% | ||
| + | \setunit{\nameyeardelim}% | ||
| + | \printfield{labelyear}% | ||
| + | \printfield{extrayear}% | ||
| + | \endgroup | ||
| + | }% | ||
| + | \quad% or \addspace | ||
| + | } | ||
| + | |||
| + | \DeclareNameAlias{sortname}{first-last} | ||
| + | </ | ||
| + | |||
| + | Sometimes it is useful to display the literature in separate groups. A filter can be used for that. | ||
| + | Here is an example how to filter out the " | ||
| + | first all non-online literature and then all online literature. | ||
| + | < | ||
| + | \defbibfilter{online}{% | ||
| + | \( \type{online} \)} | ||
| + | |||
| + | \defbibfilter{offline}{% | ||
| + | \( \not \type{online} \)} | ||
| + | |||
| + | \printbibliography[heading=offline, | ||
| + | \printbibliography[heading=online, | ||
| + | </ | ||
