ebook icon indicating copy to clipboard operation
ebook copied to clipboard

Make failed. Undefined control sequence (\passthrough)

Open wizofe opened this issue 6 years ago • 17 comments

System Information:

MAC OSx High Sierra 10.13.2
Darwin UNKNOWN 17.3.0 Darwin Kernel Version 17.3.0; root:xnu-4570.31.3~1/RELEASE_X86_64 x86_64
pandoc version 2.1.1
pdfTeX 3.14159265-2.6-1.40.18 (TeX Live 2017)
XeTeX 3.14159265-2.6-0.99998 (TeX Live 2017)

Changed the Makefile parameters to be compatible with pandoc 2.1.1 as follows:

--pdf-engine $(XELATEX)
--top-level-division=chapter -N --toc --toc-depth=2 \

After running make though I am getting:

fatal: your current branch 'master' does not have any commits yet
> Error producing PDF.
! Undefined control sequence.
<recently read> \passthrough

l.7517   \passthrough

make: *** [pdf] Error 43

wizofe avatar Jan 21 '18 18:01 wizofe

Hi, @wizofe. Could you post your full updated Makefile recipe for the pdf target, and not just a couple lines? On first glance, it seems like the line continuation \ at the end of your --pdf-engine line is missing.

As for the fatal: your current branch 'master' does not have any commits yet error, how are you cloning the repository?

timparenti avatar Jan 21 '18 19:01 timparenti

Hi @timparenti! Thanks for your answer ⌨️My Makefile paste follows. As for the git fatal, I git forked & cloned the repo on my account.

TITLE=A Friendly Introduction\\\\to Software Testing
AUTHOR=Bill Laboon
DEDICATION=for AKS and CKN


# If pandoc or xelatex are not in your PATH, specify their locations here:
PANDOC= pandoc
XELATEX= xelatex

MD_FILES=       $(wildcard text/*.md)


pdf:    main.tex tex_files
# Uses date of most recent commit in repo
        $(PANDOC) main.tex -o software-testing-laboon-ebook.pdf \
                --pdf-engine $(XELATEX) \
                --top-level-division=chapter -N --toc --toc-depth=2 \
                -M documentclass="book" \
                -M classoption="twoside" \
                -M classoption="letterpaper" \
                -M geometry="margin=1.25in" \
                -M title="\Huge{\textbf{${TITLE}}}" \
                -M author="\LARGE{${AUTHOR}}" \
                -M date="{\Large\textcopyright~\textbf{$(shell git log -1 --date=iso --format='%ai' | cut -c-10 )}}\\\\Compiled in PDF\LaTeX{}\endgraf\textit{${DEDICATION}}"

tex_files:      compiled_tex/ $(patsubst text/%.md,compiled_tex/%.tex,$(MD_FILES))
compiled_tex/:
        mkdir -p compiled_tex/
compiled_tex/%.tex:     text/%.md
        $(PANDOC) text/$*.md \
                --listings --highlight-style kate \
                -o compiled_tex/$*.tex


clean:
        rm -rf compiled_tex/
        # Remove temporary compilation directories, if they still exist
        rm -rf tex2pdf*/

.PHONY: pdf tex_files clean

wizofe avatar Jan 21 '18 20:01 wizofe

Hi @wizofe. I was getting the same issue under windows. I am using Pandoc 2.1.1 and MiKTeK 2.9.6520 x64 with a custom build script - essentially batch file that creates the PDF and epub

I managed to trace my problem to this file - lines 670-672

41_advanced_unit_testing.md

image

For some odd reason the emitted latex code does not parse very well and i'm not an expert in latex commands. I changed it to the following, which is probably not the best solution, but it generates the PDF without issues. image

yonush avatar Jan 31 '18 02:01 yonush

@yonush Any chance you'd be able to provide the (bad) LaTeX code that pandoc generates for those lines as they appear in this repo? It's possible it's a bug in the upstream project, which has happened here before.

timparenti avatar Feb 14 '18 05:02 timparenti

@timparenti This appears to be the bad code generated by Pandoc that breaks. image This is the excerpt from the input.log image

yonush avatar Feb 14 '18 23:02 yonush

Yep, with Pandoc 2.1.1, I get the following in compiled_tex/41_advanced_unit_testing.tex at lines 1106–1115:

\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\tightlist
\item
  \passthrough{\lstinline!int j = 7;!}
\item
  \passthrough{\lstinline&System.out.println("Bark!");&}
\item
  \passthrough{\lstinline!foo--;!}
\end{enumerate}

I finally got around to looking at this more, and greping through the compiled_tex/ files, I see most \lstinlines use a ! delimiter, but those with ! in them use ". It seems & is the third choice if both ! and " are used, and the "Bark!" line here is the only place that happens in our text.

Ampersands are funny creatures in LaTeX. They generally need to be escaped when you want them to be treated as literal. It seems that something about the dummy \passthrough command Pandoc introduced recently to help with escaping is not actually expecting these ampersands.

Probably & should just be removed from the list of characters that can delimit a \lstinline in Pandoc's LaTeX writer, since it requires special treatment, which was recognized in https://github.com/jgm/pandoc/commit/24acb714c185139ef3a02a7437cd1c64f85c0198 just before 2.1.1 was released. Interestingly, _ should probably meet the same fate, but it's less likely to crop up as an issue since it's currently the sixteenth-choice delimiter.

I've just opened https://github.com/jgm/pandoc/pull/4369 against the upstream project to do this. Thanks for reporting this behavior!

timparenti avatar Feb 15 '18 00:02 timparenti

@timparenti Hello, I would like to translate to Spanish but I do not know how. I would like to do it by means of pull request :)

TiburonzinGT avatar Feb 22 '18 03:02 TiburonzinGT

@shadowz10 I would love to see this translated into Spanish! It may make more sense to do this a separate repository, though, instead of as a PR.

laboon avatar Feb 22 '18 04:02 laboon

@laboon I do translations for utopian.io and they require that it be with PR. I would love to contribute with translations into Spanish by doing PR.

TiburonzinGT avatar Feb 22 '18 04:02 TiburonzinGT

@laboon If you want, I could set up a repository so I can work making a PR. thanks

TiburonzinGT avatar Feb 22 '18 18:02 TiburonzinGT

@laboon @wizofe Just a note that jgm/pandoc#4369 was merged upstream on 26 April 2018 and released in pandoc 2.2 on 27 April 2018.

I just re-ran this with a fresh upgrade to pandoc 2.2.1 via Homebrew (with the updated Makefile parameters for pandoc 2.x in #144), and it now compiles cleanly, so this one can probably be closed now.

timparenti avatar May 21 '18 16:05 timparenti

@wizofe if this works for you, let me know and I can close it up.

laboon avatar May 21 '18 16:05 laboon

What is your latex version? I update my pandoc to 2.2.1, but still

! Undefined control sequence.
<recently read> \passthrough

it seems that latex lstlistings did not contain this command.

bubifengyun avatar Jun 14 '18 07:06 bubifengyun

The above error still persists for me too. I am using the latest build of Pandoc 2.2.1 and recently updated MikTex.

yonush avatar Jun 14 '18 09:06 yonush

I just download texlive 2018, still

bubifengyun avatar Jun 14 '18 09:06 bubifengyun

I need renewcommand passthrough, I had solved, ref https://stackoverflow.com/questions/50854429/bookdown-undefined-control-sequence-recently-read-passthrough

bubifengyun avatar Jun 16 '18 16:06 bubifengyun

I needed to apply the following diff in order to get make to work:

diff --git a/main.tex b/main.tex
index a65621d..a02003b 100644
--- a/main.tex
+++ b/main.tex
@@ -1,5 +1,7 @@
 % documentclass and similar are handled by pandoc in the Makefile.

+\newcommand{\passthrough}[1]{\lstset{mathescape=false}#1\lstset{mathescape=true}}
+
 \begin{document}

 % Cover matter is handled by pandoc in the Makefile.

ggilmore avatar Jul 29 '18 18:07 ggilmore