brucemiller / LaTeXML

LaTeXML: a TeX and LaTeX to XML/HTML/ePub/MathML translator.
http://dlmf.nist.gov/LaTeXML/
Other
961 stars 101 forks source link

`\bigskip` in section title incorrectly inserts `<break/>` #2255

Open nschloe opened 1 year ago

nschloe commented 1 year ago

MWE:

\documentclass{article}
\begin{document}

\section{\bigskip Introduction}

\end{document}

LaTeX output:

screenshot_2023-10-30-205902

LaTeXML output:

  <section inlist="toc" xml:id="S1">
    <tags>
      <tag>1</tag>
      <tag role="refnum">1</tag>
      <tag role="typerefnum">§1</tag>
    </tags>
    <title><tag close=" ">1</tag><break/>Introduction</title>
  </section>
dginev commented 1 year ago

This almost looks like a feature to me - the author asked for a skip, and the request was honored.

I think you can easily add a CSS rule that styles these breaks with display:none; whenever they are undesired, right?

We should also be mindful that this example is dangerously close to "markup abuse", where many treatments would be equally good/bad.

nschloe commented 1 year ago

I'd been under the impression that LaTeXML tries to replicate LaTeX as closely as possible. LateX ignores \bigskip in titles. ⟹ So does LaTeXML.

I think you can easily add a CSS rule that styles these breaks with display:none; whenever they are undesired, right?

You can actually produce newlines in titles with

\section{\\Introduction}

screenshot_2023-10-30-212029

In LaTeXML, this correctly gives

<title><tag close=" ">1</tag><break/>Introduction</title>

Ignoring <break/>s in titles would also ignore those rightful linebreaks.

dginev commented 1 year ago

I'd been under the impression that LaTeXML tries to replicate LaTeX as closely as possible.

We also try to be semantics-preserving as closely as possible, and sometimes layout and semantics clash. We usually favor semantics in such cases.

But maybe there is a good reason why \bigskip is ignored in this context and we should too - would need to read more about how it gets dropped in LaTeX-proper to be sure.

nschloe commented 1 year ago

FWIW, it was my impression that the authors mistakenly wanted to create a vertical "big skip" between 1 and Introduction, and they thought \bigskip does this (while really LaTeX does it automatically).