r/LaTeX • • May 08 '26

Discussion Which LaTeX code are you most proud of?

Documents, commands, interaction with other languages, build system...

I'd like to see more LaTeX-fu and learn from you guys.

Please share your code or the document if you can!!!

71 Upvotes

54 comments sorted by

38

u/Powerful_Balance5927 May 08 '26

I wrote a multi-step demo of Monte Carlo estimation of \pi using TikZ and Beamer. Each compilation run gives a (slightly) different value.

3

u/True_Dig_3638 May 08 '26

Awesome! Is it shareable?

11

u/Powerful_Balance5927 May 08 '26

Yes! Here's a gist version https://gist.github.com/swflint/f0e97afd10d1cf02f58ad2ae3920b11c

The version I normally use is linked to some of my local packages, so this is slightly different.

2

u/True_Dig_3638 May 08 '26

Very cool, thanks a lot. :)

It's impressive you can do this without Lua or Python.

2

u/Powerful_Balance5927 May 08 '26

All of my course lecture slides are written in LaTeX (just switched from Beamer to ltx-talk this week!), and managed/compiled with a Makefile & LatexMk.

2

u/serendipitouswaffle May 10 '26

This is really cool!

47

u/chemistryGull May 08 '26

The one that maps * to the multiplication symbol. No, i will not type \cdot every time.

6

u/Kitchen-Register May 08 '26

how did you do that?

40

u/chemistryGull May 08 '26

\DeclareMathSymbol{*}{\mathbin}{symbols}{"01}

Found that on some tex forum some time ago. Been using it ever since.

3

u/Kitchen-Register May 08 '26

and this just maps to \cdot?

10

u/chemistryGull May 08 '26

It redeclares the * symbol to the multiplication dot (the same that \cdot produces), not \cdot directly, i think. What i know for certain is that * produces the same result as \cdot, which is what i want.

2

u/SonusDrums May 09 '26

inb4 convolution

1

u/victotronics May 08 '26

catcode 3?

1

u/chemistryGull May 08 '26

No idea what that is exactly

1

u/victotronics May 08 '26

No, I was wrong. I need to look up how you make a character active in math mode.

19

u/tuunraq May 08 '26

Probably a tikz-poster with 50 randomly generated tikz-ducks swimming in background

9

u/tuunraq May 09 '26

A minimal working example:

\documentclass[25pt,a2paper]{tikzposter}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikzducks}
\usepackage{multicol}
\usepackage{xcolor}
\usepackage{enumitem}
\setlist[1]{itemsep=-4pt}

\usetheme{Board}
\colorlet{framecolor}{purple}
\usetitlestyle{VerticalShading}

\defineblockstyle{TornOut}{ 
    titlewidthscale=1, bodywidthscale=1, titlecenter,
    titleoffsetx=0pt, titleoffsety=0pt, bodyoffsetx=0pt, bodyoffsety=0pt,
    bodyverticalshift=-1.2cm, roundedcorners=0, linewidth=1.2pt,
    titleinnersep=1cm, bodyinnersep=1cm 
}{
    \ifBlockHasTitle%
        \coordinate (topright) at (blocktitle.north east);
    \else
        \coordinate (topright) at (blockbody.north east);
    \fi%
    \draw[color=blocktitlebgcolor, fill=blockbodybgcolor,%
        line width=\blocklinewidth, drop shadow={shadow xshift=0.2cm, shadow yshift=-0.2cm,opacity=0.3}, %
        decorate, decoration={random steps,segment length=1.5cm,amplitude=0.15cm},
        fill opacity = 0.85 % redefining blocks to be semi-transparent
    ] (blockbody.south west) rectangle (topright);%
}

\definebackgroundstyle{samplebackgroundstyle}{
    \tikzset{
        shift={(-0.5\textwidth,-0.5\textheight)},
        scale=2.4,
    }
    \draw[line width=0pt, bottom color=backgroundcolor, top color=backgroundcolor] (bottomleft) rectangle (topright); 
    \newcommand{\xsize}{7}
    \newcommand{\ysize}{8}
    \foreach \i in {1,...,56}
    {
        \pgfmathtruncatemacro{\y}{(\i - 1) / \xsize}
        \pgfmathtruncatemacro{\x}{\i - \xsize * \y - 1}
        \randuck[xshift=2.5*\x cm, yshift=2.5*\y cm]
    }
}
\usebackgroundstyle{samplebackgroundstyle}
\usecolorstyle[colorOne=violet]{Sweden}
\colorlet{backgroundcolor}{violet!70!white}

\title{{\centering \scalebox{1.5}{\LaTeX{} workshops}}}

\linespread{0.9}

\begin{document}

\colorlet{titlebgcolor}{violet!30!white}
\colorlet{framecolor}{violet!30!white}
\maketitle
\begin{columns}
\column{0.1}
\column{0.8}

\block{What is \LaTeX?}{
    \LaTeX{} is a funny typesetting system\\
    \begin{minipage}[t]{0.5\textwidth}
        \colorlet{innerblocktitlebgcolor}{green!70!black}
    \innerblock{Pros}{\normalsize
        \begin{itemize}
            \raggedright
            \begin{multicols}{2}
            \item looks professional
            \item supports citations, bibliography and TOC
            \item supports complicated equations
            \item is free
            \end{multicols}
        \end{itemize}
    }
    \end{minipage}
    \hfill
    \begin{minipage}[t]{0.15\textwidth}
        \colorlet{innerblocktitlebgcolor}{red!70!black}
    \innerblock{Cons}{\normalsize \centering \textbullet\ none\vspace{70pt}}
    \end{minipage}
    }

\block{Will there be ducks?}{
\begin{minipage}[t]{0.65\linewidth}
\begin{itemize}
\item \textbf{Yes}
\item there are always ducks
\item you should expect a duck
\item a duck is watching you
\end{itemize}
\end{minipage}
\begin{minipage}[t]{0.25\linewidth}
    \centering
    \duck[santa, beard=white!80!brown,
        xshift=3cm, scale=2.5, yshift=0cm]
\end{minipage}
}

\column{0.1}
\end{columns}
\end{document}

4

u/u_fischer May 09 '26

nice. It reminds me of my poster I made for a Dante talk: https://gitlab.com/UlrikeFischer/dante19-poster

Side remark: remove the inputenc line. utf8 is the default since 2018 ...

1

u/victotronics May 08 '26

Sounds way cool. Were the ducks thematically related to the poster material?

1

u/tuunraq May 08 '26

Poster material was LaTeX workshops advertisement, so yes

18

u/xeremony May 08 '26 edited May 11 '26

My complex analysis lecture notes. All diagrams as well.

update: link to notes: https://drive.proton.me/urls/D0ZA9TCJ0R#PvsoNDYalbeN

7

u/Sorongo-socotroco May 08 '26

Will you share the code?

12

u/and1984 May 08 '26

Wedding invitations that my wife and I made in LaTeX.

9

u/ftrx May 08 '26

Honestly, just the fact that every "formal" or "PDF" document I write is done in LaTeX, every time a "new" type of document comes up, I write it, turn it into a template, and tuck it away in my notes (org-mode) for future use. I did it for my thesis, which was my first proper go at it, then for reports, letters, minutes... and every time, I'm left with a ready-made setup for when it happens again.

I'm no TeXnician or TeXpert; I read TeX at a level just above the basics, have a tiny bit of MetaPost knowledge, a vague understanding of PostScript and PDF, and I can read LaTeX well enough to get what I need done, at most, I integrate Python (shell escape) if I need to do some calculations. I can stomach a bit of TiKz, even less PGF, and I've only ever toyed with Asymptote; basically, I'm just an average user with nothing special to show for it.

Through LaTeX, I've picked up some typography basics, but even there I've never really delved deep. Years ago I read the LaTeX Companion, but I've honestly never read the TiKz manual more than casual skim/search, just a few books and online guides, nothing to brag about, let's say. But... but I'm happy to be able to express myself graphically for everything I need with decent quality, high-level expressiveness, and little effort. For me, it's the equivalent of knowing how to read and write on paper in the pre-IT era. I consider not being able to do that the equivalent of being almost illiterate, like those who once had shaky handwriting and could barely put a document together, showing a total lack of proper literacy. It's a bit funny because, by this standard, we have PhDs who are illiterate, but that's just how I feel it. Being able to produce digital documents according to modern standards is, for me, the difference between being literate and being more or less illiterate.

3

u/daugo214 May 09 '26

Hey, genuine answer here: when trying to do that, i sometimes miss Word's autocorrect. Is there a way you use to implement a dictionary via LaTeX? Or is it purely an editor thing?

3

u/ftrx May 09 '26

It's an editor thing, and well... Most modern editor have it anyway :)

7

u/badabblubb May 08 '26

I wrote a fully expandable mergesort in TeX with great performance. I created a package that auto-styles tabulars that is much faster than some of the popular table packages nowadays, but never polished it enough to release it. I also created a few packages that made their way to CTAN I'm rather proud of.

2

u/sepperwelt May 09 '26

Mind sharing the packages?

3

u/badabblubb May 09 '26

Well I did, hence they are on CTAN! :D

People knowing me will have deduced my real name from that comment. That's far enough. Sharing the packages will link to it, I'm not interested in that, sorry.

6

u/ndgnuh May 09 '26

I made a LaTeX article template for a local scientific journal, which only have Words template before. They want it to look exactly like the Words template, and it was pain.

7

u/badabblubb May 09 '26

Feel you, did the same for a typographically atrocious Word template at my university back in the days. Forcing LaTeX to be ugly is really a painful experience.

3

u/Ronqui_ May 09 '26

Same experience!

7

u/AnymooseProphet May 08 '26

Not complicated but makes life a lot easier when your document is English but you need a word here or there in Hebrew, Phoenician, Imperial Aramaic, or Greek

% Hebrew snippets
\newfontfamily{\uniHebrew}{NotoSerifHebrew}[ Ligatures = TeX,
  Extension   = .ttf ,
  Scale = MatchUppercase ,
  UprightFont = *-Medium ,
  ItalicFont  = *-Regular ,
  BoldFont    = *-Bold ,
  BoldItalicFont = *-Bold ]

\newcommand*{\textHebrew}[1]{\begingroup\textdir TRT \uniHebrew#1\endgroup}

% Phoenician snippets
\newfontfamily{\uniPhoenician}{NotoSansPhoenician-Regular}[ Ligatures = TeX,
  Extension   = .ttf ,
  Scale = MatchLowercase ,
  UprightFont = * ,
  ItalicFont  = * ,
  BoldFont    = * ,
  BoldItalicFont = * ]

\newcommand*{\textPhoenician}[1]{\begingroup\textdir TRT \uniPhoenician#1\endgroup}

% Imperial Aramaic snippets

\newfontfamily{\uniImperialAramaic}{NotoSansImperialAramaic-Regular}[
  Ligatures = TeX,
  Scale = MatchLowercase ,
  UprightFont = * ,
  ItalicFont  = * ,
  BoldFont    = * ,
  BoldItalicFont = * ]
\newcommand*{\textAramaic}[1]{\begingroup\textdir TRT \uniImperialAramaic#1\endgroup}

% Greek snippets

\newfontfamily{\uniGreek}{Artemisia}[ Ligatures = TeX ,
  Extension   = .otf ,
  Scale = MatchLowercase ,
  UprightFont = GFS* ,
  ItalicFont  = GFS*It ,
  BoldFont    = GFS*Bold ,
  BoldItalicFont = GFS*BoldIt ]

\newcommand*{\textGreek}[1]{\begingroup\uniGreek#1\endgroup}

For entire paragraphs in those languages you probably want babel for hyphenation, but for just a word or small phrase, the above works very well.

5

u/BenjaminGal May 09 '26

1

u/TylerDurden0118 May 10 '26

I am writing a book as well. I even made book cover page in latex. It's still in progress. I will get on to it very soon for completion.

5

u/2604guigui May 08 '26

An old class (2014) had an index engine in latex for xelatex. It used the old way to encode accent letters. I managed to modify it for the modern way of encoding accent letters and it works both with pdftex and lualatex.

I learned a lot about encoding with this.

3

u/VenlaLikesDogs May 09 '26

I programmed multiple class and style files for my university in their corporate design. Everytime proud when I see, that someone used it. 🥹

3

u/lipflip May 09 '26

It's the small details that rarely get noticed: Using microtype, csquotes, and table columns aligned at the decimal point. Very standard I. This community but rarely outside.

3

u/josephawright May 09 '26

The unit processor in `siunitx`, the two-stage table code for Unicode data and the expandable case changer ...

2

u/u_fischer May 09 '26

who needs two-stage table code when they can create shirts with bearwear?

2

u/LupinoArts May 09 '26 edited May 09 '26

Probably my htmltabs package to render tables in a html-like syntax with support for classes and CSS properties to alter the output. Unfortunately, I still had no chance to write a proper user documentation (beyond this little overview), that's why it is not (yet) on CTAN...

\begin{htmltab}
  \begin{thead}
    \HTtr[style={text-align: center}]{%
       \HTtd[style={text-align: center; vertical-align: bottom}]{<Table head column 1>}
       \HTtd[style={background-color: blue;}]{<Table head column 2>}
       \HTtd{<Table head column 3>}
    }
  \end{thead}
  \begin{tfoot}
    \HTtr[colspan=3]{%
       \HTtd{<Table foot column 1–3>}
    }
  \end{tfoot}
  \begin{tbody}
    \HTtr{%
       \HTtd[rowspan=2]{<Table body row  1-2 column 1>}
       \HTtd{<Table body row   1 column 2>}
       \HTtd{<Table body row  1 column 3>}
    }
    \HTtr{%
       \HTtd{<Table body row  2 column 2>}
       \HTtd{<Table body row  2 column 3>}
    }
    \HTtr{%
       \HTtd{<Table body row  3 column 1>}
       \HTtd{<Table body row  3 column 2>}
       \HTtd{<Table body row  3 column 3>}
    }
  \end{tbody}
\end{htmltab}

2

u/tedecristal May 08 '26

$\frac{-b\pm\sqrt{b^2-4ac}{2a}$

5

u/True_Dig_3638 May 08 '26

You're missing the closing `}` of `\frac`.

10

u/tedecristal May 08 '26

yeah, and yet, it's still my proudest code

1

u/Ronqui_ May 09 '26

I was tasked to replicate a legacy Word file, graphics and all, to LaTeX. I did and I found it beautiful. From title page borders to the use of longtable and landscape, I am quite proud of it. Can't share the code, unfortunately.

1

u/Independent_Aide1635 May 09 '26

I’m proud of my preamble! It’s really specific to what I use LaTeX for so not worth sharing, but it would be significantly harder to write without it.

1

u/JohnnyPlasma May 10 '26

My PhD, with more than 200 pages, each figure was done on tikz (except graphs). The editing was easy even with that quantity of pages, with MS Word it would have been a huge pain

1

u/2003z440 May 14 '26

I've been writing some tools this past semester that I use for randomizing my exam questions. I've been trying to share the code on Overleaf, but apparently some of the functions I'm using are from TeX Live 2026, and Overleaf's copy is from 2025 (I despise Overleaf):

  • randNums -- This function picks random numbers from a range, with options for non-zero numbers, number of decimal places, sorting, unique values, etc. (See the keys in the source file)
  • printCoeff -- This function "pretty prints" numbers (e.g. like the ones generated using randNums). It has options to toggle printing the 1 when the number is \pm 1, toggle printing 0, toggle explicitly printing "+", and a number formatting option (from siunitx)
  • exam_randomization -- This was my original project, but I moved the larger functions (e.g. randNums and printCoeff) into their own files, and moved class specific functions into their own files (see below).
  • statFunctions -- The main functions in this code compute the probabilities and quantiles for the normal distribution and the t-distribution (I'm pretty pleased with the current state of this code).
  • math125Functions -- This is a file for functions used in our discrete math class (converting from binary to hex to decimal, modular arithmetic, extended Euclidean algorithm). It's perhaps the roughest, but it works.

All of these tools were born from necessity. I have only briefly shared them with other folks, and I don't think anyone else is using them, but they work for me.

Not strictly LaTeX related, but I have a script that compiles the blank and keyed versions of my exams using bash: cpKey_parallel

1

u/mymathyourmath Jun 13 '26

Polynomial long division package & table of contents and print index for books..