serhii.net

In the middle of the desert you can say anything you want

16 Jan 2024

LaTeX best practices and compression

EDIT: this is becoming a more generic thingy for everything I’d ever need to refer to when writing a paper, later I’ll clean this mess.

Resources – DREAM Lab links to https://dream.cs.umass.edu/wp-content/uploads/2020/04/Tips-and-Best-Practices.pdf. Until I set up a system to save PDF info, I’ll paste it as screenshots here:

2024-01-16-170245_722x940_scrot.png 2024-01-16-170254_723x941_scrot.png 2024-01-16-170303_728x798_scrot.png

ChatGPT summarized the relevant pages of the PDF file thus, but didn’t do it well, mostly rewriting myself:

General Formatting

  • Smart Quotes: Use `x’ and ``x’’ for single and double quotes respectively.
  • Large Numbers: Write large numbers as 54{,}000.
  • Word Breaking: Use - to suggest hyphenation points in long words, including ones that already have hyphens inside them. Such words are likely to go over margins etc.: multi-discipli\-nary
    • EDIT: If I don’t want a word to get broken, use mbox: \caption{Worldwide distribution of \mbox{plantNaturalist-}500k}1
    • EDIT2: the extdash package is even better, same link
    • EDIT3: If you want to allow linebreaks somewhere but without a dash and only if needed, it’s long\allowbreak word2
  • Overflow Lines: \begin{sloppypar}... for paragraphs where latex goes over the margin.
  • Float Positioning: Place figures and tables at the top of the page for readability: \begin{figure}[t]
  • Center Align Floats: Use \centering for aligning tables and figures.

Specific Elements

  • Non-Breaking Space: Use the tilde (~) to keep words together, including always
    • before citations: sth~\cite{whatever}
    • after numbers in text
    • before figure/section references
  • Emphasize vs. Bold: Prefer \emph over bold or \textit.

Equations and Macros

  • Macros: Create macros for things that will be changed later, such as DATASET NAMES. \newcommand{\system}{SQuID\xspace}
    • \xspace here adds as space unless end of sentence. Package \usepackage{xspace}

Spacing and Sizing

  • Paragraph Spacing: Use \smallskip, \medskip, and \bigskip, instead of \vspace
  • Line and Text Width: Use fractions of \linewidth or \textwidth.
  • Resizing Tables/Figures: Use \resizebox with appropriate dimensions.

Other bits I’ll need but don’t want to transcribe but need to mention at least once so I can search for them later

Compression hacks (see pics)

Paper writing hacks: 2024-01-18-142614_564x519_scrot.png

Even more

best practices - When should I use non-breaking space? - TeX - LaTeX Stack Exchange lists ALL the places where Knuth wanted people to put nonbreaking spaces, incl:

  • 1)~one 2)~two
  • Donald~E. Knuth
  • 1,~2
  • Chapter~12

Less obvious and not from him:

  • I~am

Also:

  • before all cites, refs
  • … and inlined equations

ALSO

ChatGPT says that citations should come before footnotes to prioritize the scholarly source over unimportant info. So this [32] 3 and not this3 [32]. Basically footnotes after all punctuation and citations. OK

EDIT: NOT PARENTHESES, THEY SHOULD BE WITHIN PARENTHESES.4 DAMN

ALSO

I sometimes write and around ~50% forgetting that ~ is a nbsp — hard to catch when reading the text.

ALSO

As when writing code I like to add some assert False (or a failing test) so that I know where I stopped the last time, \latexstopcompiling here is a neat way to make sure I REALLY finis ha certain line I started but not finished.

Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus