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

latex to epub problem (\ifdefined not defined) #9049

Open
apaeffgen opened this issue Sep 1, 2023 · 4 comments
Open

latex to epub problem (\ifdefined not defined) #9049

apaeffgen opened this issue Sep 1, 2023 · 4 comments

Comments

@apaeffgen
Copy link

Explain the problem.
pandoc -f latex -t epub test.tex -o test.epub
Testfile is exported from a ipynb file to latex. I guess the environment variable makes the problem.
\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}
If you comment out the environment, it works.

%\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}

Pandoc version?

MacOS Ventura 13.5.1
pandoc 3.1.7
Features: +server +lua
Scripting engine: Lua 5.4

test_tex.txt

@apaeffgen apaeffgen added the bug label Sep 1, 2023
@jgm
Copy link
Owner

jgm commented Sep 1, 2023

Actually I think the problem comes from:

\ifdefined\Shaded\renewenvironment{Shaded}{\begin{tcolorbox}[frame hidden, sharp corners, interior hidden, borderline west={3pt}{0pt}{shadecolor}, enhanced, breakable, boxrule=0pt]}{\end{tcolorbox}}\fi

Comment that out and it works. It may have something to do with parsing of the environment options in square brackets: removing [frame hidden, sharp corners, interior hidden, borderline west={3pt}{0pt}{shadecolor}, enhanced, breakable, boxrule=0pt] also makes it work.

Interestingly, changing

\ifdefined\Shaded\renewenvironment{Shaded}{\begin{tcolorbox}[frame hidden, sharp corners, interior hidden, borderline west={3pt}{0pt}{shadecolor}, enhanced, breakable, boxrule=0pt]}{\end{tcolorbox}}\fi

to

\renewenvironment{Shaded}{\begin{tcolorbox}[frame hidden, sharp corners, interior hidden, borderline west={3pt}{0pt}{shadecolor}, enhanced, breakable, boxrule=0pt]}{\end{tcolorbox}}

also makes it work!

@jgm
Copy link
Owner

jgm commented Sep 1, 2023

For completeness, the error message is:

Error at "t.tex" (line 245, column 2):
unexpected end of input
expecting \end{snugshade}

@jgm
Copy link
Owner

jgm commented Sep 1, 2023

OK, the root cause, I think, is that \ifdefined is not something pandoc currently understands. Changing \ifdefined\Shaded to \iftrue fixes things.

@jgm
Copy link
Owner

jgm commented Sep 1, 2023

It would be difficult to accurately implement \ifdefined, because at best pandoc would know about control sequences explicitly defined in the file it's parsing. We could limit it to those, but then we'd get some false negatives. Still, that may be better than simply failing.

TODO? Implement \ifdefined

@jgm jgm changed the title latex to epub problem latex to epub problem (\ifdefined not defined) Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants