IACR / latex

Latex classes for IACR publications. We will start with the new journal proposal.
9 stars 2 forks source link

[bug?] Using `$$` to delimit mathematics breaks line numbering in the enclosing environment. #263

Open cdesaintguilhem opened 3 weeks ago

cdesaintguilhem commented 3 weeks ago

The following minimal code:

\documentclass[version=submission]{iacrcc}

\begin{document}

\begin{definition}
  This definition has line numbers as expected.
\end{definition}

\begin{definition}[test]
  However, if I write a long definition with an equation written with \verb|$$|
  delimiters such as this one:
  $$ 2 + 2 = 5, $$
  then the lines before the equation no longer have line numbers. But the ones
  afterwards do.
\end{definition}

\begin{itemize}
  \item It seems like it happens in other environments.
  \item The previous item didn't have maths using \verb|$$|.
    $$ 9.\dot{9} = 10 \implies 0 = 1 $$
    However this one does and the line number between the start of the item and
    the end of the maths have disappeared.
  \item On the other hand, this is not the case with \verb|\[ \]| delimiters.
    \[ \sum_{i=0}^{\infty} (-1)^{i} \frac{1}{2i + 1} = \frac{\pi}{4} \]
\end{itemize}

\end{document}

produces a PDF where some line numbers are missing.

I did a quick search for issues and PRs related to line numbering but couldn't find anything; my apologies if this is a duplicate.

jwbos commented 3 weeks ago

This is a known problem. See for example this discussion. Let me dive a bit into lineno and check if we can fix this.

kmccurley commented 3 weeks ago

$$ is a plain TeX primitive for display mathematics and should be replaced by \[...\] in LaTeX to delimit display mathematics. The LaTeX user's guide mentions this in the very last section under "Miscellaneous"

cdesaintguilhem commented 3 weeks ago

@kmccurley I'm aware of this, and I personally use \[...\], but I was reviewing a paper and noticed this behaviour, so I tried to reproduce it and opened the issue here. I doubt that iacrcc.cls can enforce the choice of LaTeX primitives over TeX ones, so it would be ideal if lineno could handle this. But I'm happy to close this issue here since the issue is with lineno and not with iacrcc.cls strictly speaking.

kmccurley commented 3 weeks ago

There is no need to close the issue - it's certainly a problem worth fixing if we can.

This is related to another thing that I encountered, namely whether to flag violations of certain "best practices" in LaTeX. I don't want to be too restrictive to authors, but some have developed really bad habits and it doesn't help to provide warnings to "nudge" them toward better practices. An example is the use of eqnarray because it's so error-prone. I had created a modification to iacrcc.cls that issues a warning about this but I never sent it for review. You might count the use of $$ as another violation of "best practices". We already have some of these built into the system (like when a title is too long). We might be able to hook into \everydisplay to issue a warning when someone uses $$ but it sounds like a nightmare to operate at this token level. It might be easier to catch it in the python that performs other tasks like parsing the bibtex. Since lineno is only used for copy editing it's probably not worth all the trouble.

There are other things like the use of \footnote in tables, or including "alt text" for images to make PDFs more accessible to sight-impaired users, e.g.,

\includegraphics[alt={Image showing the a four-round Feistel network}]{fig1}

This issue is probably not the place to capture a list of "LaTeX best practices" though.