Skip to content

Instantly share code, notes, and snippets.

@gatlinnewhouse
Last active February 11, 2026 02:00
Show Gist options
  • Select an option

  • Save gatlinnewhouse/1f7be6c923bbb70f70973615102db09d to your computer and use it in GitHub Desktop.

Select an option

Save gatlinnewhouse/1f7be6c923bbb70f70973615102db09d to your computer and use it in GitHub Desktop.
Some popular LaTeX packages with comments about what they are

Popular LaTeX Packages

Fonts and Symbols

\usepackage{lmodern} % better i18n Postscript version of Knuth's cm fonts
\usepackage{amsmath,amssymb} % math symbols and commands
\usepackage{amsfonts} % math fonts
\usepackage{amsthm} % for theorems
\usepackage[amsmath,thmmarks,hyperref]{ntheorem} % also for theorems
\usepackage{fixmath} % ISO conform greek letters
\usepackage{cool} %  retain mathematical meaning of its expressions in addition to the typesetting instructions, easier export to mathematica etc
\usepackage[all,warning]{onlyamsmath} % show warnings for $$...$$ and eqnarrays
\usepackage[utf8]{inputenc} % support utf8
\usepackage[T1]{fontenc} % resolve some deficiencies and inconsistencies in OT1 fontencoding
\usepackage{inconsolata} % code listings font, could also use FiraMono
\usepackage{wasymsym} % more glyphs
\usepackage{nicefrac} % perhaps better fraction typesetting as 1/2
\usepackage{newtxtext,newtxmath} % modern times-like font with math support
\usepackage{newpxtext,newpxmath} % palatino-like font with math support
\usepackage{helvet} % Helvetica, `\renewcommand{\familydefault}{\sfdefault}`
\usepackage{eulervm} % Zapf's Euler fonts
\usepackage{tgpagella} % TeXGyre Pagella fonts
\usepackage{libertine} % Linux Libertine fonts (elegant, book-quality serif)
\usepackage{fourier} % Fourier fonts (Utopia-based)
\usepackage{courier} % Courier font (monospaced)
\usepackage{times} % Times Roman font
\usepackage{mathptmx} % Times font for math
\usepackage{mathpazo} % Palatino font with math support
\usepackage{color} % color support
\usepackage{xcolor} % extended colors
\usepackage{textcomp} % text companion fonts (additional symbols like ©, ®, ™)
\usepackage{lettrine} % decorative drop caps, e.g. Spongebob The
\usepackage{Typocaps} % provides decorative drop cap fonts
\usepackage{pdfcomment} % PDF Annotations & Sticky Notes
\usepackage{soul} % text decorations, so = s p a c e d  o u t, small caps, underline, strikethrough
\usepackage{shadowtext} % text with shadows
\usepackage{soulutf8} % soul package with UTF-8 support
\usepackage{soulpos} % soul with position tracking
\usepackage{lua-ul} % underlining for LuaLaTeX
\usepackage{relsize} % relative font sizing (\smaller, \larger)
\usepackage{anyfontsize} % any font size without warnings
\usepackage{scalefnt} % scale current font
\usepackage{dsfont} % doublestroke fonts (for \mathds{1} indicator function)

Typography & Professional Typesetting

\usepackage{ellipsis} % proper spacing around ellipses
\usepackage{ragged2e} % improved ragged-right/left/center commands
\usepackage{footmisc} % customize footnote appearance and behavior
\usepackage{fnpct} % manage interaction of footnotes and punctuation
\usepackage{ftnright} % footnotes in right column
\usepackage{endnotes} % endnotes instead of footnotes
\usepackage{pagenote} % page notes
\usepackage{sidenotes} % margin notes and figures
\usepackage{leading} % adjust line spacing precisely

Microtype Options

Typographic adjustments to make your text look better. Documented here.

For best results use pdfTeX >= 1.40. See the package documentation here.

\usepackage[
  protrusion=true, activate={true,nocompatibility}, % activate protrusion and expansion
  final, % enable microtype; use "draft" to disable
  tracking=true, kerning=true, spacing=true, % enable these techniques
  factor=1100, % add 10% to the protrusion amount (default is 1000)
  stretch=10, shrink=10 % reduce stretchability/shrinkability
]{microtype}
\SetTracking{encoding={*}, shape=sc}{40}

Layout, Page Setup

\usepackage[margins=2.5cm,a4paper]{geometry}
\usepackage{titlesec} % section title formatting
\usepackage{titling} % control over \maketitle
\usepackage{appendix}
\usepackage{fancyhdr} % stylish headers and footers
\usepackage{scrlayer-scrpage} % KOMA-Script header/footer (modern alternative)
\usepackage{extramarks} % additional marks for headers/footers
\usepackage{cmap} % Make PDF files searchable and copyable
\usepackage{richtext} % input forms and annotations from pdf spec
\usepackage{adjustbox} % scale, trim, clip, and frame content
\usepackage{balance} % Balances the columns of the last page
\usepackage{multicol} % quickly typeset multicolumn text in single column document
\usepackage{multirow} % multiple rows in tables
\usepackage{parskip} % control indentation and spaces between paragraphs
\usepackage{tabto}
\usepackage{pdflandscape} % landscape tables and figures
\usepackage{pdflscape} % also does landscape pages
\usepackage{enumitem} % easily change labels with [label=(\roman*)] or similar
\usepackage[super]{nth} % typeset 1st, 2nd, 3rd, etc.
\usepackage{upref} % upright font for all \ref and \eqref
\usepackage{emptypage} % for the book class, removes headers and footers from empty pages at end of chapters
\usepackage[subtle]{savetrees} % controversial, can help text tighter with subtle mode
\usepackage{setspace} % line spacing control (single, 1.5, double spacing)
\usepackage{indentfirst} % indent first paragraph after section headings
\usepackage{lastpage} % reference to last page number
\usepackage{afterpage} % execute command after current page is complete
\usepackage{placeins} % float barriers with \FloatBarrier
\usepackage{rotating} % rotate objects (tables, figures)
\usepackage{wrapfig} % wrap text around figures
\usepackage{marginnote} % better margin notes than \marginpar
\usepackage{mparhack} % fixes margin paragraph placement
\usepackage{marginfix} % fixes margin note positioning
\usepackage{ifoddpage} % conditionals for odd/even pages
\usepackage{typearea} % KOMA-Script page layout (alternative to geometry)
\usepackage{crop} % crop marks for printing
\usepackage{needspace} % ensure minimum space on page
\usepackage{nextpage} % issue page breaks to next odd/even page
\usepackage{floatpag} % different page styles for float pages
\usepackage{everypage} % hooks for every page

Lists & Enumerations

\usepackage{paralist} % compact lists, inline lists
\usepackage{outlines} % easy nested lists
\usepackage{easylist} % easy list creation
\usepackage{tasks} % horizontal lists (like multiple choice)
\usepackage{shortlst} % compact lists across columns

Quotations

\usepackage{epigraph} % epigraphs (quotes before chapters)
\usepackage{quotchap} % decorative chapter quotes
\usepackage{quoting} % advanced quotation environments
\usepackage{dirtytalk} % simple quotation marks

Linguistic Typography

\usepackage{gb4e} % linguistic examples
\usepackage{linguex} % linguistic examples (alternative)
\usepackage{expex} % linguistic examples (another alternative)
\usepackage{cgloss4e} % interlinear glosses
\usepackage{covington} % linguistics macros
\usepackage{phonetic} % phonetic symbols
\usepackage{tipa} % IPA symbols
\usepackage{vowel} % vowel charts

Counters & Numbering

\usepackage{chngcntr} % change counter dependencies
\usepackage{remreset} % remove counter resets
\usepackage{fmtcount} % format counter output (text, roman, etc.)
\usepackage{moreenum} % additional enumeration styles
\usepackage{alphalph} % extended alphabetic counters

String & Data Manipulation

\usepackage{substr} % substring operations
\usepackage{stringstrings} % string manipulation
\usepackage{xstring} % advanced string operations
\usepackage{datatool} % database/CSV tools
\usepackage{forloop} % for loops in LaTeX
\usepackage{pgffor} % advanced loops (part of TikZ but standalone)
\usepackage{multido} % repeated operations
\usepackage{coolstr} % string manipulation
\usepackage{coollist} % list operations

Science and Language Typesetting

\usepackage{steinmetz} % electrical engineering notation
\usepackage{braket} % dirac notation
\usepackage{simplewick} % simple wick contractions
\usepackage{bm} % bold math symbols
\usepackage{physics} % typing of physics equations faster, simpler and equations easier to read
\usepackage[\arc-separator = \,, retain-explicit-plus, inter-unit-product =\cdot, detect-weight=true, detect-family=true, range-phrase=--, range-units=single]{siunitx} % typeset SI units
\usepackage{units} % typeset units (older alternative to siunitx)
\usepackage{numprint} % format numbers with spacing
\usepackage{ziffer} % European-style number formatting
\usepackage[version=4]{mhchem} % typeset chemical symbols and equations
\usepackage{nicematrix} % enhanced matrix environments
\usepackage[makeroom]{cancel} % cancel terms in equations
\usepackage{circledsteps} % circled numbers for step-by-step explanations
\usepackage{algpseudocodex} % beautiful pseudocode
\usepackage{systeme} % typeset systems of linear equations and inequalities
\usepackage{acronym} % Expand acronyms at least once
\usepackage{asymptote} % 2D and 3D TeX-Aware Vector Graphics Language, useful for the computationally complex
\usepackage{sagetex} % Embed Sage code and plots
\usepackage{polynom} % Macros for manipulating polynomials
\usepackage{blochsphere} % Draw pseudo-3D diagrams of Bloch spheres
\usepackage[normalem]{ulem} % strikethrough text
\usepackage{censor} % censor text like the CIA
\usepackage{verse} % typeset poetry
\usepackage{fancyvrb} % specify font, box, and use external files for verbatim environments
\usepackage{chemfig,chemmacros} % drawing chemical structures and reaction schemes
\usepackage{bohr} % atomic models
\usepackage{babel} % better localization and multilingual support
\usepackage{polyglossia} % modern replacement for babel (XeLaTeX/LuaLaTeX)
\RequirePackage[ngerman=ngerman-x-latest]{hyphsubst} % better hyphenation for other languages
\usepackage[retainorgcmds]{IEEEtrantools} % sophisticated equation arrays
\usepackage{csquotes} % easier quotations with \enquote{}
\usepackage{mathtools} % mathclap for long summations, extends amsmath
\usepackage{listings} % code blocks
\usepackage{minted} % code blocks with syntax highlighting (requires Pygments)
\usepackage{upquote} % typeset quotes as straight vertical quotes in verbatim environments (like code)

Algorithms & Pseudocode

\usepackage{algorithm} % algorithm float environment
\usepackage{algorithmicx} % base package for algpseudocode
\usepackage{algorithmic} % pseudocode formatting (older style)
\usepackage{algpseudocode} % part of algorithmicx (modern alternative)
\usepackage{algcompatible} % compatibility with algorithmic
\usepackage{algorithm2e} % alternative algorithm package with different syntax
\usepackage{syntax} % BNF grammar notation
\usepackage{rail} % railway diagrams for syntax
\usepackage{ebnf} % EBNF notation
\usepackage{bytefield} % packet/bitfield diagrams
\usepackage{binhex} % binary and hexadecimal numbers

Calculations & Arithmetic

\usepackage{fp} % fixed-point arithmetic
\usepackage{calculator} % perform calculations
\usepackage{spreadtab} % spreadsheet-like calculations in tables

Enhanced Mathematics

\usepackage{cases} % enhanced cases environment
\usepackage{empheq} % emphasize equations with boxes, colors
\usepackage{witharrows} % arrows with explanations in math
\usepackage{tensor} % tensor notation
\usepackage{diffcoeff} % derivatives and differentials
\usepackage{derivative} % alternative derivative notation
\usepackage{esint} % extended integral symbols
\usepackage{commath} % common math notation shortcuts
\usepackage{intervals} % interval notation
\usepackage{mleftright} % better spacing for \left \right
\usepackage{stmaryrd} % St Mary Road symbols
\usepackage{esvect} % vector arrows
\usepackage{xfrac} % nice-looking inline fractions like ¹/₂
\usepackage{thmtools} % enhanced theorem styling and management

Graphics, Captions, Tables

\usepackage[table,dvipsnames]{xcolor}
\usepackage{graphicx} % including figures, rotating or scaling text
\usepackage{float} % allows you to use `H` to specify where floats go stronger
\usepackage{tikz,tikz-3dplot} % 2d and 3d figures
\usepackage{pgfplots} % 2d and 3d plotting
\usepackage{getmap} % Download OpenStreetMap maps for use in documents
\usepackage{pdfpages} % include entire PDF pages
\usepackage[justification=centering, labelfont={small,bf}, font={small}]{caption}
\usepackage{capt-of} % captions outside float environments
\usepackage{subcaption} % subfigures and subtables (modern approach)
\usepackage{subfig} % subfigures (older alternative to subcaption)
\usepackage[outline]{contour} % outlined text
\usepackage{overpic} % overlay text/graphics on included images
\usepackage{eso-pic} % add picture commands to every page
\usepackage{wallpaper} % add watermarks/backgrounds
\usepackage{background} % page backgrounds
\usepackage{draftwatermark} % watermark for drafts
\usepackage{pict2e} % improved picture environment
\usepackage{curves} % curved lines in picture environment
\usepackage{epic} % extended picture commands
\usepackage{eepic} % extension to epic
\usepackage{transparent} % transparent graphics
\usepackage{trimclip} % trim and clip graphics inline

Advanced Tables and Arrays

\usepackage{array} % create custom columns for formatting tabular material on a per-column basis
\usepackage{colortbl} % colored tables
\usepackage{booktabs} % nicer looking tables with professional rules
\usepackage{longtable} % multi-page tables
\usepackage{threeparttable} % tables with notes
\usepackage{dcolumn} % decimal-aligned columns
\usepackage{tabularx} % greater dynamism in column widths
\usepackage{tabulary} % auto-sizing columns like tabularx but better
\usepackage{tabularray} % modern, powerful alternative to tabular
\usepackage{arydshln} % dashed lines in arrays/tables
\usepackage{makecell} % line breaks and formatting in table cells
\usepackage{diagbox} % diagonal lines in table cells
\usepackage{hhline} % fine control over table lines
\usepackage{ltablex} % combines longtable and tabularx
\usepackage{xltabular} % combination of longtable and tabularx
\usepackage{ltxtable} % another longtable + tabularx combo

Boxes, Frames & Environments

\usepackage{tcolorbox} % highly customizable colored boxes
\usepackage{mdframed} % framed environments that can break across pages
\usepackage{framed} % simple framed environments
\usepackage{fancybox} % various box styles
\usepackage{dashbox} % dashed border boxes
\usepackage{environ} % create custom environments more easily
\usepackage{boxedminipage} % boxed minipages
\usepackage{bclogo} % boxes with logos/icons
\usepackage{awesomebox} % boxes with FontAwesome icons
\usepackage{varwidth} % variable-width minipage

Tikz Setup Options

\usetikzlibrary{calc, arrows, arrows.meta, positioning, decorations.pathreplacing, decorations.markings, decorations.text, calligraphy, pgfplots.dateplot}
\usepackage{circuitikz} % circuit diagrams using TikZ
\usepackage{tikzpeople} % stick figure people
\usepackage{tikz-cd} % Commutative Diagrams
\usepackage{tikzmark} % mark positions in text for later tikz use
\usepackage{forest} % draw trees (linguistic, decision, etc.)
\usepackage{tikz-qtree} % quick tree drawing
\usepackage{tree-dvips} % linguistic trees
\usepackage{dirtree} % directory tree structures

References and Links

\usepackage{hyperref} % pdf metadata and to create links within the document and to URLs
\usepackage{bookmark} % improved PDF bookmarks (better than hyperref alone)
\usepackage{url} % typesets URLS
\usepackage[noadjust]{cite} % [1,2,3,4,5] --> [1-5]  useful in hep-th!
\usepackage{natbib} % natural sciences citation styles
\usepackage{biblatex} % modern bibliography system
\usepackage{apacite} % APA citation style
\usepackage[notref,notcite]{showkeys} % useful when writing the paper
\usepackage[noabbrev]{cleveref} % load after hyperref for nice commands to reference within document
\usepackage{varioref} % variable page references ("on the next page", etc.)
\usepackage{nameref} % reference by section name
\usepackage{titleref} % reference section titles
\usepackage{xr} % cross-reference between documents
\usepackage{xr-hyper} % xr with hyperref support
\usepackage{zref} % extended referencing system
\usepackage{refcount} % access reference counters
\usepackage{fncylab} % format labels and references
\usepackage{prettyref} % pretty formatting for references
\usepackage{refstyle} % reference style customization
\usepackage{smartref} % context-aware references
\usepackage[nottoc,numbib]{tocbibind}
\usepackage{glossaries} % glossary and acronym support
\usepackage{glossaries-extra} % easier abbreviations and enhanced glossaries
\usepackage{notoccite} % prevent citations in TOC from appearing in bibliography

Index & Glossary

\usepackage{makeidx} % index generation
\usepackage{imakeidx} % improved index creation with multiple indices
\usepackage{crossreftools} % tools for cross-referencing
\usepackage{nomencl} % nomenclature lists

Document Quality and Linting

\RequirePackage[l2tabu, orthodox]{nag} % warns when you accidentally use deprecated LaTeX constructs from l2tabu, use before document class
\RequirePackage{snapshot} % Automatically creates a .dep file listing all packages and versions used
\usepackage{refcheck} % Warns about unused \label commands or undefined \ref commands
\usepackage{showlabels} % Displays all \label, \ref, \cite in the margins for easy reference
\usepackage{chktex} % LaTeX linter, checks for common errors
\usepackage{lacheck} % syntax checker for LaTeX documents
\usepackage{strict} % turns LaTeX warnings into errors for stricter checking
\usepackage{silence} % selectively suppress specific warnings
\usepackage{prelim2e} % mark document as preliminary/draft with timestamps
\usepackage{fixme} % insert fixme notes with different severity levels
\usepackage[draft]{changes} % track document changes and revisions
\usepackage{lineno} % line numbers for drafts/reviews

Tools & Utilities

\usepackage{datetime2} % set datetime formats
\usepackage{datetime} % format dates and times
\usepackage{advdate} % date calculations
\usepackage[english]{isodate} % ISO formatted dates
\usepackage{pdfcrypt} % pdf encryption
\usepackage{iftex,expl3} % engine detection and LaTeX3 programming
\usepackage{etoolbox} % if-then and programming tools
\usepackage{xparse} % more flexible macros (LaTeX3 command parser)
\usepackage{xspace} % smart spacing after macros
\usepackage{ifthen} % conditional commands
\usepackage{calc} % infix notation for length calculations
\usepackage{lipsum} % lorem ipsum dummy text
\usepackage{blindtext} % more dummy text options
\usepackage{todonotes} % todo notes in margins

Conditionals & Document Variants

\usepackage{comment} % comment out large sections
\usepackage{version} % include/exclude document versions
\usepackage{versions} % similar to version package
\usepackage{optional} % optional document parts
\usepackage{ifdraft} % conditionals for draft/final mode
\usepackage{ifpdf} % conditionals for PDF vs DVI output
\usepackage{ifxetex} % detect XeTeX engine
\usepackage{ifluatex} % detect LuaTeX engine

Macro & Command Tools

\usepackage{regexpatch} % patch commands with regex
\usepackage{xpatch} % extend and patch macros
\usepackage{letltxmacro} % safe \let for LaTeX macros

File I/O

\usepackage{currfile} % access current file name
\usepackage{filecontents} % write external files from document
\usepackage{catchfile} % read external file contents into macro
\usepackage{newfile} % read/write to multiple external files
\usepackage{import} % better \input with relative paths
\usepackage{vc} % version control integration
\usepackage{gitinfo2} % git repository information in document

External Program Integration

\usepackage{pythontex} % execute Python code in LaTeX
\usepackage{pythonhighlight} % Python syntax highlighting
\usepackage{gnuplottex} % embed gnuplot code
\usepackage{auto-pst-pdf} % automatic conversion of PSTricks to PDF

PDF Features & Metadata

\usepackage{pdfx} % create PDF/A and PDF/X compliant documents
\usepackage{embedfile} % embed arbitrary files in PDF
\usepackage{attachfile2} % attach files to PDF
\usepackage{ocgx2} % PDF layers (optional content groups)
\usepackage{hyperxmp} % embed XMP metadata in PDF
\usepackage{pdfprivacy} % remove metadata for privacy
\usepackage{pageslts} % page count for last page in different counters
\usepackage{totpages} % total page count
\usepackage{navigator} % presentation navigation

Author Tools

\usepackage{authoraftertitle} % access \MyTitle, \MyAuthor after \maketitle
\usepackage{authblk} % multiple authors with affiliations

Document Classes & Templates

% These are document classes, not packages, but included for reference:
% \documentclass{beamer} % presentations
% \documentclass{memoir} % book class with extensive features
% \documentclass{article} % standard article class
% \documentclass{book} % standard book class
% \documentclass{report} % standard report class

Misc.

Automultiplechoice for typesetting exams.

\usepackage{verbatim} % enhanced verbatim environment
\usepackage{abstract} % abstract customization
\usepackage{musixtex} % musical scores
\usepackage{skak} % chess notation and boards
\usepackage{crossword} % crosswords
\usepackage{sudoku} % sudoku puzzles
\usepackage{qrcode}
\usepackage{barcode}
\usepackage{menukeys} % keyboard shortcuts

Usage Notes

Had Claude generate these, need to verify them. Do not take these as gospel.

Font Package Conflicts

  • Use only ONE main font package to avoid conflicts. Choose between:
    • newtxtext,newtxmath (Times-like)
    • newpxtext,newpxmath (Palatino-like)
    • mathptmx (Times for math, older)
    • mathpazo (Palatino for math, older)
    • fourier (Utopia-based)
    • libertine (Linux Libertine)
  • Font encoding: Always load fontenc with [T1] option before font packages
  • Input encoding: inputenc with [utf8] is default in modern LaTeX but explicit for compatibility
  • Microtype: Load AFTER all font packages for best results (requires pdfTeX ≥ 1.40)

LaTeX Engine Compatibility

  • pdfLaTeX only: microtype (full features), pdflandscape, pdflscape, pdfpages
  • XeLaTeX/LuaLaTeX: Use polyglossia instead of babel, fontspec for system fonts
  • LuaLaTeX specific: lua-ul (better underlining), luacode (Lua integration)
  • Engine detection: Use iftex, ifxetex, ifluatex, or ifpdf for conditional compilation

Citation & Bibliography Conflicts

  • Choose ONE citation system:
    • Modern: biblatex (with biber backend)
    • Traditional: natbib (with BibTeX)
    • Simple: cite (basic citation compression)
  • DO NOT mix natbib and biblatex
  • Load order: Bibliography packages → hyperrefcleveref

Subfigure Package Conflicts

  • Choose ONE subfigure package:
    • Modern (recommended): subcaption
    • Older: subfig
    • Ancient (deprecated): subfigure
  • DO NOT load multiple subfigure packages together

Table Package Selection

  • Modern approach (recommended): tabularray - replaces most table packages
  • Traditional approach:
    • Basic: tabularx (dynamic width) or tabulary (auto-sizing)
    • Multi-page: longtable or xltabular/ltxtable (combines features)
    • Never use tabu - it's deprecated and buggy

Critical Load Order

  1. Before \documentclass: nag (if using \RequirePackage)
  2. Early in preamble:
    • inputenc, fontenc (encoding)
    • Font packages
    • microtype
    • babel or polyglossia
  3. Mid preamble: Most packages (amsmath, graphics, etc.)
  4. Late in preamble (near end):
    • hyperref (almost last)
    • bookmark (after hyperref, enhances it)
    • cleveref (MUST be after hyperref)
    • glossaries (after hyperref)
  5. After \begin{document}: Some packages like biblatex need setup commands

Hyperref Compatibility

  • Load hyperref LATE (but not absolutely last)
  • Before hyperref: Most packages, especially those defining floats/counters
  • After hyperref: bookmark, cleveref, glossaries, algorithm (if conflicts occur)
  • Hyperref options: Pass [hidelinks] to remove colored boxes, [unicode] for Unicode support

Draft vs. Final Mode

  • Draft mode indicators: ifdraft, prelim2e, draftwatermark, lineno, showlabels
  • Disable in draft: microtype (use draft option), expensive graphics rendering
  • Enable in final: Full microtype, all graphics, remove showkeys, fixme, todonotes

Mathematics Package Loading

  • Essential order: amsmathmathtools (extends amsmath) → other math packages
  • Theorem packages: Use EITHER amsthm OR ntheorem, not both
  • Bold math: Load bm after math fonts for proper bold symbols
  • Physics: physics package conflicts with some journals - check guidelines

Graphics & TikZ

  • TikZ libraries: Load after \usepackage{tikz} via \usetikzlibrary{...}
  • PGFPlots: Requires TikZ, specify version with \pgfplotsset{compat=1.18}
  • External graphics: graphicx is the modern version (use over graphics)
  • Circuit diagrams: circuitikz is built on TikZ

Code Listings

  • Choose ONE:
    • listings (traditional, works everywhere)
    • minted (modern, requires Python Pygments and -shell-escape)
  • With minted: Compile with pdflatex -shell-escape (security risk - use carefully)
  • Verbatim: fancyvrb for enhanced features, upquote for straight quotes in code

Document Quality Tools

  • Linting workflow:
    1. nag before \documentclass - catches deprecated commands
    2. refcheck during writing - finds unused labels
    3. showlabels during review - see all labels in margins
    4. fixme / todonotes - track needed changes
    5. chktex (external tool) - comprehensive linting
  • Version tracking: snapshot auto-creates .dep file with all package versions

Algorithm Packages

  • Modern: algorithmicx + algpseudocode (flexible)
  • Alternative: algorithm2e (different syntax, more features)
  • Float environment: algorithm provides the float wrapper
  • Old style: algorithmic (legacy, use algorithmicx instead)

Color Packages

  • Use xcolor (extended features) rather than basic color
  • Load early if using table option: \usepackage[table,dvipsnames]{xcolor}
  • For colored tables: Load before colortbl

Spacing & Layout

  • Margin notes: Use marginnote (modern) over \marginpar (basic)
  • Line spacing: setspace for document-wide, leading for fine control
  • Page breaks: needspace ensures minimum space, afterpage delays commands

Quotation Marks

  • Use csquotes with \enquote{} for proper quotation marks in any language
  • Babel integration: csquotes auto-adjusts to babel language
  • Avoid: Manual `` and '' - not language-aware

Units & Numbers

  • Modern: siunitx (comprehensive SI units and number formatting)
  • Older alternatives: units (deprecated), SIunits (obsolete)
  • Number formatting: numprint for separators without full siunitx

Linguistic Packages

  • Phonetics: tipa (IPA symbols) requires T3 encoding
  • Glosses: Choose ONE - gb4e, linguex, or expex
  • Trees: forest (modern, powerful) or tikz-qtree (simple)

Conditional Compilation

  • Version control: comment, version, versions, optional
  • Build modes: ifdraft, ifpdf (PDF vs DVI)
  • Engine detection: ifxetex, ifluatex, iftex

PDF Features

  • Archival PDFs: pdfx for PDF/A or PDF/X compliance (strict requirements)
  • Metadata: hyperxmp for XMP metadata, pdfprivacy to remove metadata
  • Layers: ocgx2 for optional content groups (interactive PDFs)
  • Attachments: attachfile2 (modern) over attachfile (older)

Box Packages

  • Modern comprehensive: tcolorbox (highly customizable, can break pages)
  • Simple frames: framed or mdframed (page-breaking frames)
  • Fixed boxes: fancybox, dashbox (simple, don't break pages)
  • Environments: environ helps create custom environments using any box package

String Manipulation

  • Modern: xstring (most powerful)
  • Alternatives: stringstrings, substr (simpler operations)
  • Data handling: datatool for CSV and database-like operations

Loop Constructs

  • Best: pgffor (part of TikZ, very flexible)
  • Alternatives: forloop (simple), multido (repetition)
  • In math: Use LaTeX3's expl3 for advanced programming

Cross-Referencing

  • Basic: \ref, \pageref
  • Smart: varioref (page-aware), cleveref (type-aware)
  • External: xr for cross-document references, xr-hyper with hyperref
  • Extended: zref for custom reference properties

Index & Glossary

  • Index: imakeidx (modern, multiple indices) over makeidx (basic)
  • Glossary: glossaries-extra (modern) over glossaries (older)
  • Acronyms: Both glossaries packages handle acronyms
  • Nomenclature: nomencl for symbol lists

Author Tools

  • Multi-author: authblk for author/affiliation formatting
  • Metadata access: authoraftertitle to reuse title/author after \maketitle
  • Change tracking: changes package for collaborative editing
  • Version control: gitinfo2 (Git), vc (general VCS)

External Program Integration

  • Python: pythontex (full execution) or pythonhighlight (syntax only)
  • Gnuplot: gnuplottex requires -shell-escape
  • Sage: sagetex requires Sage installation and -shell-escape
  • Security: All -shell-escape packages pose security risks - use carefully

File Operations

  • Include files: import (better paths) over basic \input
  • File info: currfile for current filename
  • Write files: filecontents (single file) or newfile (multiple streams)
  • Read files: catchfile to capture file contents into macro

Common Conflicts

  • babel vs polyglossia: Use babel for pdfLaTeX, polyglossia for XeLaTeX/LuaLaTeX
  • inputenc with XeLaTeX/LuaLaTeX: Not needed, causes errors (these engines are UTF-8 native)
  • times vs mathptmx: Use mathptmx (includes math support)
  • algorithm + hyperref: Load algorithm before hyperref or use \usepackage[algo2e]{algorithm2e}

Performance Considerations

  • Slow compilation: microtype, minted, TikZ externalization, sagetex, pythontex
  • Speed up: Use draft mode, externalize TikZ pictures, cache minted output
  • Large documents: Use \includeonly for partial compilation, consider standalone for figures

Special Considerations

  • Journal submissions: Many journals ban certain packages (physics, minted, etc.) - check guidelines
  • arXiv: Supports most packages but no -shell-escape (minted, pythontex won't work)
  • Overleaf: Full TeX Live, supports most packages, minted works (shell-escape enabled)
  • MiKTeX vs TeX Live: Feature parity, but package names may differ slightly

Recommended Minimal Setup

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}  % Optional in modern LaTeX
\usepackage{lmodern}          % Better fonts
\usepackage{microtype}        % Better typography
\usepackage{amsmath,amssymb} % Math
\usepackage{graphicx}         % Graphics
\usepackage{booktabs}         % Tables
\usepackage{hyperref}         % Hyperlinks (late)
\usepackage[noabbrev]{cleveref} % Smart references (after hyperref)

Debugging Tips

  • Package conflicts: Load packages one at a time to identify conflicts
  • Load order errors: Check .log file for "Option clash" or "Command already defined"
  • Missing packages: Use TeX Live/MiKTeX package manager, not manual installation
  • Version issues: \listfiles before \begin{document} lists all package versions in log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment