Table of Contents:
- Latex Packages & Tricks
- Control float environments
- "subcaption": Create sub-figures and sub-tables
- "enumitem": Control layout of itemize, enumerate & description
- "booktabs": Beautiful tables
pandas.DataFrame.to_latex()
: Dump data from Python to LaTex- "makecell": Force line breaks inside a table cell
- "tabularx": Tabulars with adjustable-width columns
- Quotation Marks and Dashes
- Resize parentheses, brackets and braces
- Overbrace and underbrace
- Math symbols and fonts
- "bm": A lazy solution to bold symbols in maths mode
- "mathtools": Beautiful maths
- "cleveref": A clever way to reference
- "xcolor": Color your LaTex
Things could make your writing easier and your paper more professional.
Overleaf is a convenient online collaborative latex writing platform. It also provides some basic latex writing tips here.
- A comprehensive answer!
- Some parameters in the above document could be very helpful
- e.g. put
\setlength{\textfloatsep}{5pt plus 1pt minus 1pt}
(default 20pt plus 2pt minus 4pt) before\begin{document}
, this would save a lot of space between top or bottom tables/figures and the text area
- Options
b
andh
are disabled fortable*
andfigure*
environments (cross-column tables and figures)
"enumitem" is a very helpful package if you want to reduce spaces in itemize/enumerate environments
- Package "enumitem"
- A simple example:
import the package first: \usepackage{enumitem}
then put
\setlist{nosep,after=\vspace{0.5\baselineskip},leftmargin=12pt}
before before \begin{document}
, this would (globally) remove separations between items, reduce the space at the bottom of list environments and reduce the left indentation to 12pt.
"booktabs" might be one of the most popular latex packages in academic writing.
- Package "booktabs"
- A simple example
- personal preference: vertical lines are ugly here, don't use them.
- A fancier example (stepped table)
- Another fancy example (with multi-columns)
- Official document
pandas.DataFrame.to_latex()
would render a pandas.DataFrame object in python to a LaTeX tabular environment "booktabs"-style table.
This package can be very helpful if you want to force line breaks inside a table cell
- Single quotation marks: ` and '
- Double quotation marks: `` and ''
- Even fancier examples
- Dashes:
-
inter-word--
page range, 1–10---
punctuation dash$-$
minus sign
- Resize automatically
- simple
\left(
and\right)
would work in most cases
- simple
- Resize manually
\[
z = \overbrace{
\underbrace{x}_\text{real} + i
\underbrace{y}_\text{imaginary}
}^\text{complex number}
\]
- A fancier example (with overlaps):
- "underoverlap": a package to handle this case
- Greek letters and math symbols
- Mathematical Fonts
\mathit{}
could be useful for long identifiers in math
- Package "mathtools"
- Examples
- one of the most useful command might be
\mathclap{}
, which can reduce spaces in subscripts, exponents, etc.
- one of the most useful command might be
- Official document
"cleveref" can help us to define unified reference formats in the global environment, so that we can keep using \cref{}
regardless of the specific reference types (equation, section, etc.) in the document.