Latex: Difference between revisions
| (8 intermediate revisions by the same user not shown) | |||
| Line 32: | Line 32: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* Note to add bibliography, you need to run <code>pdflatex</code>, <code>bibtex</code>, <code>pdflatex</code> | * Note to add bibliography, you need to run <code>pdflatex</code>, <code>bibtex</code>, <code>pdflatex</code> or <code>rubber --pdf</code>. | ||
==Usage== | ==Usage== | ||
| Line 83: | Line 83: | ||
\end{minipage} | \end{minipage} | ||
</pre> | </pre> | ||
===Sections=== | ===Sections=== | ||
| Line 103: | Line 102: | ||
You can define your own commands using <code>\newcommand</code> | You can define your own commands using <code>\newcommand</code> | ||
<syntaxhighlight lang="latex"> | <syntaxhighlight lang="latex"> | ||
\newcommand{notdone}{{\color{red} Not done!!}} | \newcommand{\notdone}{{\color{red} Not done!!}} | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 160: | Line 159: | ||
For multirow cells, you can use <code>\multirowcell{5}{Numbers\\from\\ 1 to 5}</code>. | For multirow cells, you can use <code>\multirowcell{5}{Numbers\\from\\ 1 to 5}</code>. | ||
By default, this will align center. You can make it align left: <code>\multirowcell{2}[0pt][l]{Number\\ Letter}</code>. | By default, this will align center. You can make it align left: <code>\multirowcell{2}[0pt][l]{Number\\ Letter}</code>. | ||
==Table Generator== | |||
[https://www.tablesgenerator.com/ https://www.tablesgenerator.com/] can generate table code from existing tables. | |||
==Figures== | ==Figures== | ||
| Line 169: | Line 171: | ||
\end{figure} | \end{figure} | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Be sure to use vector figures (pdf or pgf) instead of raster ones (png, jpeg).<br> | |||
See [https://timodenk.com/blog/exporting-matplotlib-plots-to-latex/ https://timodenk.com/blog/exporting-matplotlib-plots-to-latex/] on how to export matplotlib to pgf. | |||
In the snippet <code>[!htbp]</code> represents the placement preferences. | |||
* <code>!</code> means to ignore some placement limitations | |||
* <code>h</code> mean to place the figure here | |||
* <code>t</code> means top of the page. | |||
* <code>b</code> means bottom of the page. | |||
* <code>p</code> means to place it on a figure only page. | |||
If you add the [https://ctan.mirrors.hoobly.com/macros/latex/contrib/float/float.pdf the float package], you can also use <code>[!H]</code> which is a more strict version of <code>[!h]</code>. | |||
===Subfigure=== | ===Subfigure=== | ||
| Line 313: | Line 327: | ||
\usepackage[linesnumbered,ruled]{algorithm2e} | \usepackage[linesnumbered,ruled]{algorithm2e} | ||
\begin{algorithm}[ | \begin{algorithm}[!htbp] | ||
\KwData{this text} | \KwData{this text} | ||
\KwResult{how to write algorithm with \LaTeX2e } | \KwResult{how to write algorithm with \LaTeX2e } | ||
| Line 395: | Line 409: | ||
</pre> | </pre> | ||
* <code>-r</code> specifies the DPI. Default is 150. | * <code>-r</code> specifies the DPI. Default is 150. | ||
===Latex Cleanup=== | |||
If you need to submit the latex, e.g. to Arxiv, you can use this tool to help clean it up: | |||
https://github.com/google-research/arxiv-latex-cleaner | |||
==Resources== | ==Resources== | ||
* [http://detexify.kirelabs.org/classify.html Detexify LaTeX handwritten symbol recognition] | * [http://detexify.kirelabs.org/classify.html Detexify LaTeX handwritten symbol recognition] | ||
[[Category:Programming languages]] | |||