kosmikus / lhs2tex

Preprocessor for typesetting Haskell sources with LaTeX
Other
99 stars 28 forks source link

Conflict with acmart #82

Open Lysxia opened 4 years ago

Lysxia commented 4 years ago

Recent versions of acmart (at least since 1.70) cause an error with \usepackage{amssymb} (issue borisveytsman/acmart#395), which lhs2tex appears to insert unconditionally:

https://github.com/kosmikus/lhs2tex/blob/34301bed0a895691631ab3acd61808411fae0711/lhs2TeX.sty.lit#L41

Example to reproduce:

% t.lhs
\documentclass{acmart}
%include polycode.fmt
% This is really because of \usepackage{amssymb}
% If you take that out of the preprocessed file the result compiles fine.
\begin{document}
\end{document}
lhs2TeX t.lhs > t.tex
pdflatex t.tex
# Output:
# ...
# ! LaTeX Error: Command `\Bbbk' already defined.
# ...
kosmikus commented 4 years ago

Yes, this is unfortunate.

The quick workaround is

\let\Bbbk\undefined

prior to including polycode.fmt

A proper solution would be to rewrite polycode.fmt to either not include amssymb if acmart is being used, or to make it generally possible to not include amssymb.

csetzer commented 2 years ago

'acmart' loads '/usr/share/texlive/texmf-dist/tex/latex/newtx/newtxmath.sty' and I found the following post https://tex.stackexchange.com/questions/564075/can-newtxmath-be-used-with-amssymb-in-pdflatex which says: "Can newtxmath be used with amssymb in PDFLaTeX?"

Answer: "The literal answer to what you asked is: yes, but you don’t want to. As egreg brought up in the comments, newtxmath defines every symbol that amssymb does, designed to match Times. The amssymb symbols are designed to go with Computer Modern"

So the solution is not to include amssymb.sty

ulysses4ever commented 1 year ago

So the solution is not to include amssymb.sty

I think this could fail outside acmart (i.e. when newtxmath is not used). I think a safer fix would be to replace amssymb with newtxmath in polycode.fmt.

alt-romes commented 7 months ago

I also ran accross this today 👍

sgraf812 commented 2 weeks ago

As fate would have it, I debugged a font error today which might be related to the workaround and the reinclusion of amssymb. Here's an MWE:

\documentclass{article}

\usepackage{biblatex}
\usepackage{newtxmath}
\usepackage{wasysym}
\usepackage{mathbbol}
\let\Bbbk\relax
\usepackage{amssymb}
\usepackage{stmaryrd}

\begin{document}

\section{$5_{\mathbf{sub}}$}

$\mathit{foo}\;\texttt{bar}\;\mathsf{baz}$

\noindent
$\mathit{foo}\;\texttt{bar}$

\end{document}

Note that I would expect both uses of foo in math mode to be printed in italics. However, this is what I get (TeXLive 2023):

Screenshot from 2024-08-22 18-00-55

Note that the first foo is not set in italics, however the second is.

There is something going on here and I don't know who is to blame. If I remove any of the packages or the section header, both foos are printed in italics.

It would perhaps be better if we included newtxmath instead.

Edit: Alas, it turns out that is only part of the solution. A re-import of newtxmath will still error out for redefinition of macros such as \iint, \iiint etc.

sgraf812 commented 2 weeks ago

I tried the simplest thing in #109 and replaced use of amstext and amssymb with newtxmath. After rebuilding my thesis, I noticed that the font errors were still present. Then I removed the \let\Bbbk\relax workaround from my LaTeX preamble and it built without font errors.