Writing Papers with LaTeX - CSUS-LLVM/OptSched GitHub Wiki

Tips and tricks for using LaTeX (Overleaf is relevant too) to write papers.


Embedded Diagrams / Drawings

To add visual graphics to the paper, you could use TikZ, but it may be more wise to use a WYSIWYG editor that can export to LaTeX. Inkscape is such an editor. You can draw your diagram as an SVG using Inkscape, then have Inkscape export to LaTeX via the command:

inkscape -D --export-latex -o TheSVG.pdf TheSVG.svg

Embed the result in LaTeX using something along the lines of:

\begin{figure}
    \centering
    \def\svgwidth{\columnwidth}
    \input{TheSVG.pdf_tex}
    \caption{A caption describing the contents of TheSVG.}
    \label{fig:thesvg}
\end{figure}

Although the key bit is:

\def\svgwidth{\columnwidth} % or choose a different column width if necessary
\input{TheSVG.pdf_tex}

Inkscape can export LaTeX renditions of SVGs even if they were not made via Inkscape.

Things to be aware of:

  • The point of this is to let LaTeX handle the text rendering.
    • This means that you can use LaTeX code inside of Inkscape. If you add a text element as $L_A$, then LaTeX will see the math and do LA.
    • This means that the positioning of text will be hard to nail down. Inkscape renders the text element using its set font, but LaTeX will render it differently, causing text alignment to be not where you might expect.
  • Make use of text alignment (left aligned, right aligned, center aligned, justified) in Inkscape. LaTeX will render the text differently, but the aligned edge of the text will be in the same place as in Inkscape.
  • Beware of changes in appearance when the figure size changes; the text doesn't automatically shrink in size to fit the space, but the shapes will.
  • Import it into LaTeX and recompile often. You want to see the result so that you can make small adjustments.

Inkscape tips

  • Use absolute positioning on elements so that they align well.
  • Choose simple numbers for element positioning and size. For example, place a 4mm-width dot every 10mm rather than a 3.933mm-width dot every 13.276mm.
  • When drawing paths, use the "Edit paths by node" tool to adjust the position of individual nodes on the path; this allows you to use absolute positioning.
    • If you resize paths, the stroke width will be inconsistent. This is why to prefer adjusting the positions of individual nodes.

Graphs

If you need to embed a graph such as a DDG, consider using Graphviz to generate a SVG, then feed the SVG into Inkscape to produce a LaTeX-embeddable image.

You may use an online version of Graphviz (e.g. https://dreampuf.github.io/GraphvizOnline/ ), or you may install Graphviz locally and run the dot command.

Citations and References

Do not manually format the bibliography. Instead, let BibTeX do it for you. The following is all that you need at the end of your paper:

\nocite{*} % REMOVE this when the paper is done. It lets you see the whole bibliography, even uncited papers.
\bibliographystyle{IEEEtran} % Or whatever style you need; perhaps an ACM style?
\bibliography{MyBib} % refers to MyBib.bib

In your separate MyBib.bib file, you'll have a sequence of BibTeX citations. If you are able to, do not format these by hand; use a BibTeX citation generator with manual adjustments as necessary. Most journal websites that have a "Generate Citation" button (looks like a quote symbol) let you select "BibTeX" as an option. The ACM Digital Library is particularly good at this: https://dl.acm.org/ . Definitely don't do all the work yourself, though. Copy as many BibTeX citations as you can from previous papers.

Definitely change the BibTeX key to something meaningful, though, e.g. Smith09 for a paper by John Smith et al. published in 2009. Then, your in-text citations will simply write \cite{Smith09} (multiple citations are \cite{Smith09,Doe12}).

Some programming projects will also give you a BibTeX citation snippet; you may have to write it yourself if they don't.

⚠️ **GitHub.com Fallback** ⚠️