jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.6k stars 3.38k forks source link

LaTeX macros for task list symbols #7924

Open allefeld opened 2 years ago

allefeld commented 2 years ago

With TeX Gyre Pagella Math as mathfont, a task list looks like this:

Screenshot_20220217_050536

The two symbols are fine on their own, but don't match exactly.

In that font, a better matching pair would be:

Screenshot_20220217_050940

Here I used the symbols □ (U+25A1 WHITE SQUARE) and ⊠ (U+22A0 SQUARED TIMES).

Checking the generated LaTeX code

\begin{itemize}
\tightlist
\item[$\square$]
  an unchecked task list item
\item[$\boxtimes$]
  checked item
\end{itemize}

I don't see a way to replace the used symbols $\square$ and $\boxtimes$ with my choice.

I propose that Pandoc instead creates code like

\begin{itemize}
\tightlist
\item[\UncheckedSymbol]
  an unchecked task list item
\item[\CheckedSymbol]
  checked item
\end{itemize}

combined with preamble code

\newcommand\UncheckedSymbol{\ensuremath\square}
\newcommand\CheckedSymbol{\ensuremath\boxtimes}

This would reproduce the current behavior, but would be customizable, either by changing the template or via \renewcommand.

jgm commented 2 years ago

It's tempting to make the default behavior using 25A1 and 22A0. But I don't think we can do that without sacrificing pdflatex-ability.. Your solution is elegant but has the drawback of making the TeX we produce less self-contained. Still, it's probably worth while on the whole.

allefeld commented 2 years ago

Still, it's probably worth while on the whole.

I would think so. There are a lot of commands in the LaTeX output which rely on packages loaded or other preamble material.

hoclun-rigsep commented 2 years ago

Your solution is elegant but has the drawback of making the TeX we produce less self-contained.

Could you not make it conditional on -s?