Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cdesaintguilhem opened this issue Oct 25, 2024 · 5 comments
Assignees

Comments

@cdesaintguilhem
Copy link
Contributor

cdesaintguilhem commented Oct 25, 2024

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.

@cdesaintguilhem cdesaintguilhem changed the title [bug? [bug?] Using $$ to delimit mathematics breaks line numbering in the enclosing environment. Oct 25, 2024
@jwbos jwbos self-assigned this Oct 25, 2024
@jwbos
Copy link
Collaborator

jwbos commented Oct 25, 2024

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
Copy link
Member

$$ 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
Copy link
Contributor Author

@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
Copy link
Member

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.

@jwbos
Copy link
Collaborator

jwbos commented Nov 27, 2024

I had a closer look and cleaned up our code, see 533d7cd.
See also Section 7 in both here and here. There is still no proper support for line numbers when using '$$' but this cleans up our code. I created a pull-request for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants