gpoore / pythontex

A LaTeX package that executes Python and other code in LaTeX documents, and includes the output
861 stars 98 forks source link

Clash with footmisc and thmtools #105

Open mlhetland opened 6 years ago

mlhetland commented 6 years ago

I'm not sure which package is to “blame,” here, as any subset of two seems to work just fine, so it's sort of arbitrary that I chose to post the issue here (mainly because the bug appeared as I tried to use pythontex along with my existing .sty files).

Here's an example document:

\documentclass{article}

\usepackage[perpage]{footmisc}
\usepackage{thmtools}
\usepackage{pythontex}

\begin{document}
Foo.
\end{document}

The ordering of the three packages doesn't seem to matter, but if one of them is removed, or if the perpage option is removed from footmisc, the error goes away.

And the error is:

TeX capacity exceeded, sorry [parameter stack size=10000].
\aliasctr@f@llow #1#2\@nil #3->
                               \ifx #1\@elt \noexpand #3\else \expandafter \...
l.7 \begin{document}
gpoore commented 6 years ago

pythontex loads fvextra to do code typesetting, and fvextra loads lineno to make its breaklines option possible. lineno and footmisc are incompatible, but apparently only if footmisc is loaded with the perpage option.

I don't know enough about lineno or footmisc to be able to suggest a quick fix for either without digging in the source code. Another option would be to "fake" the loading of lineno, so that it isn't ever actually loaded (instructions). That would probably work as long as you never need to use the breaklines option when typesetting code.

mlhetland commented 6 years ago

OK, thanks! Further resolution here is not crucial to me, so feel free to close this, if you wish. I'll leave it open, though, in case it's something you'll want to look into in the future. (Maybe I will, too, if I get around to it :-))

gpoore commented 6 years ago

I will at least add a note in the pythontex and/or fvextra documentation before closing this.

mlhetland commented 6 years ago

The faking trick worked nicely. Perhaps one could add an option to pythontex (and fvextra) to prevent the loading of lineno? Somethink like breaklines=false or something? Or if you add a note about it in the docs, that should be fine, I'm sure :-)

gpoore commented 6 years ago

Ideally, I could remove the fvextra dependency on lineno, since it only needs a few lineno features, and lineno can conflict with several packages. I'll have to look into this more the next time I'm working on fvextra.