# LaTeX Error: Missing \begin{document} for no apparent reason

1. Package pgfkeys Error: I do not know the key '/tcb/library/skins'

2. Undefined control sequence. \tcolorboxenvironment

3. LaTeX Error: Missing \begin{document}

4. LaTeX Error: Environment reviewer-comment undefined

5. LaTeX Error: \begin{response} on input line 55 ended by \end{reviewer-comment}

‎\documentclass[10pt]{article}‎

% Allow Unicode input (alternatively, you can use XeLaTeX or LuaLaTeX)
% ‎\usepackage[utf8]{inputenc}‎
\usepackage{microtype, xparse, tcolorbox}‎
\newenvironment{reviewer-comment}{}{}‎
\tcbuselibrary{skins}‎‎‎

\tcolorboxenvironment{reviewer-comment}{empty‎, ‎left=1em‎, ‎top=1ex‎,
‎bottom=1ex‎, ‎borderline west={2pt}{0pt}{black!20}‎,}
‎\ExplSyntaxOn‎
‎\NewDocumentEnvironment{response}‎{‎+‎m O{black!20}‎}{
\IfValueT{#1}‎{
\begin{reviewer-comment~}‎
\setlength\parindent{2em}‎
\noindent‎
‎\ttfamily #1‎
‎\end{reviewer-comment~}‎
}
\par\noindent\ignorespaces‎‎
}{‎\bigskip\par‎}

‎\NewDocumentCommand \Reviewer {m}‎ {
}
\ExplSyntaxOff‎
\AtBeginDocument{\maketitle\thispagestyle{empty}\noindent}‎

% ‎You can get probably get rid of these definitions‎:
\newcommand\meta[1]{$\langle\hbox{#1}\rangle$}‎
\newcommand\PaperTitle[1]{\textit{#1}''}‎

\title{Statement on the Revision of \meta{Paper ID} \\‎
Based on the Referees' Report}‎
\author{Author1 \and Author2 \and Author3}‎
\date{\today}‎

‎\begin{document}‎
‎This statement concerns our revision of the \meta{Paper ID} paper‎,
‎entitled \PaperTitle{\meta{Paper Title}}‎, ‎based on the referees'‎
‎report‎.

\Reviewer{\#1}‎
\begin{response}{First comment.}‎
Response to the first comment‎.
‎\end{response}‎
\begin{response}{Second comment.}‎
Response to the second comment‎.
‎\end{response}‎

‎\Reviewer{\#2}‎
‎\begin{response}{First comment.}‎
‎Response to the first comment‎.
‎\end{response}‎‎

‎\end{document}‎

• You have several rather nasty invisible unicode chars in this code that you need to have removed before this MWE is usable, I get an error at the \documentclass line when copying the MWE to my editor and compiling it. – daleif Jun 8 '18 at 10:56
• Are you working in an arabic or similar env? some of the chars at least pdflatex complains about are U+200e – daleif Jun 8 '18 at 10:57
• No, I'm not. I'm working in an English environment. – Vahid Tadayon Jun 8 '18 at 11:00
• Well, the other day I wrote a script to find non-latex supported chars in a text. It finds U+200E at least 60+ times in this MWE, as far as I understand U+200E is a marker that specifies that the writing direction from now on is left to right. – daleif Jun 8 '18 at 11:03
• Texpad Version 1.7.43 (210) – Vahid Tadayon Jun 13 '18 at 7:21

There are several things at play here. First of the MWE contains some 60+ invisible unicode chars (U+200E, LEFT-TO-RIGHT MARK). Compiling the MWE with pdflatex causes an error about unicode 200E being unknown to pdflatex.

In xelatex things are different, it knows about unicode and to it these invisible chars are just normal chars.

In the first line of the MWE, there is an U+200E at the end of the line. Xelatex will try to typeset this char, but is not allowed as we are in the preamble, hence the

LaTeX Error: Missing \begin{document}


You get the same error using \documentclass{article} a

The other error messages are presumably caused by your editor running in something like nonstopmode aka, if it gets an error try to recover, that guess does not always go so well and errors may accumulated. Therefore one always concentrate on fixing the first error.

In the earlier text below. you'll find my markup of where the 200E chars are hiding in the doc.

Here is a cleaned version:

\documentclass[10pt]{article}

% Allow Unicode input (alternatively, you can use XeLaTeX or LuaLaTeX)
% \usepackage[utf8]{inputenc}
\usepackage{microtype, xparse, tcolorbox}
\newenvironment{reviewer-comment}{}{}
\tcbuselibrary{skins}

\tcolorboxenvironment{reviewer-comment}{empty, left=1em, top=1ex,
bottom=1ex, borderline west={2pt}{0pt}{black!20},}
\ExplSyntaxOn
\NewDocumentEnvironment{response}{+m O{black!20}}{
\IfValueT{#1}{
\begin{reviewer-comment~}
\setlength\parindent{2em}
\noindent
\ttfamily #1
\end{reviewer-comment~}
}
\par\noindent\ignorespaces
}{\bigskip\par}

\NewDocumentCommand \Reviewer {m} {
}
\ExplSyntaxOff
\AtBeginDocument{\maketitle\thispagestyle{empty}\noindent}

% You can get probably get rid of these definitions:
\newcommand\meta[1]{$\langle\hbox{#1}\rangle$}
\newcommand\PaperTitle[1]{\textit{#1}''}

\title{Statement on the Revision of \meta{Paper ID} \\
Based on the Referees' Report}
\author{Author1 \and Author2 \and Author3}
\date{\today}

\begin{document}
This statement concerns our revision of the \meta{Paper ID} paper,
entitled \PaperTitle{\meta{Paper Title}}, based on the referees'
report.

\Reviewer{\#1}
\begin{response}{First comment.}
Response to the first comment.
\end{response}
\begin{response}{Second comment.}
Response to the second comment.
\end{response}

\Reviewer{\#2}
\begin{response}{First comment.}
Response to the first comment.
\end{response}

\end{document}


Running this through xelatex we get the error

! LaTeX Error: Environment reviewer-comment  undefined.


which is caused by defining that env as reviewer-comment~ note the tilde at the end. Under \ExplSyntaxOn the char ~ is an explict space. So reviewer-comment is not defined whereas reviewer-comment (space at the end) is.

Just remove those two ~ and it works just fine.

BTW you are not using any code that needs \ExplSyntaxOn the interfaces explained in the xparse manual does not need it.

Earlier text:

Too long for comment, here is what the MWE looks like after I run it through my "look for unicode chars pdfLaTeX does not support", \NOPE just markes the position and the number of the char. All those \NOPE{200e} makes pdflatex croak. I have no idea what is wrong with your writing env since it adds all those otherwise hidden chars.

It seems pdflatex is a lot better at complaining about unicode issues than xelatex.

You can copy the MWE into https://w3c.github.io/xml-entities/unicode-names.html, to see what chars it is made of.

You get U+200e LEFT-TO-RIGHT MARK &lrm; all over the place. These are invisible, but counts as chars in the preamble by xelatex and lualatex so you get an error.

BTW If I remove the 200E chars from the MWE, and remove the ~ in \begin/end{reviewer-comment~}‎, then the MWE compiles just fine i both pdflatex and xelatex (testing under TeX Live 2018)

\documentclass[10pt]{article}\NOPE{200e}

% Allow Unicode input (alternatively, you can use XeLaTeX or LuaLaTeX)
% \NOPE{200e}\usepackage[utf8]{inputenc}\NOPE{200e}
\usepackage{microtype, xparse, tcolorbox}\NOPE{200e}
\newenvironment{reviewer-comment}{}{}\NOPE{200e}
\tcbuselibrary{skins}\NOPE{200e}\NOPE{200e}\NOPE{200e}

\tcolorboxenvironment{reviewer-comment}{empty\NOPE{200e}, \NOPE{200e}left=1em\NOPE{200e}, \NOPE{200e}top=1ex\NOPE{200e},
\NOPE{200e}bottom=1ex\NOPE{200e}, \NOPE{200e}borderline west={2pt}{0pt}{black!20}\NOPE{200e},}
\NOPE{200e}\ExplSyntaxOn\NOPE{200e}
\NOPE{200e}\NewDocumentEnvironment{response}\NOPE{200e}{\NOPE{200e}+\NOPE{200e}m O{black!20}\NOPE{200e}}{
\IfValueT{#1}\NOPE{200e}{
\begin{reviewer-comment~}\NOPE{200e}
\setlength\parindent{2em}\NOPE{200e}
\noindent\NOPE{200e}
\NOPE{200e}\ttfamily #1\NOPE{200e}
\NOPE{200e}\end{reviewer-comment~}\NOPE{200e}
}
\par\noindent\ignorespaces\NOPE{200e}\NOPE{200e}
}{\NOPE{200e}\bigskip\par\NOPE{200e}}

\NOPE{200e}\NewDocumentCommand \Reviewer {m}\NOPE{200e} {
}
\ExplSyntaxOff\NOPE{200e}
\AtBeginDocument{\maketitle\thispagestyle{empty}\noindent}\NOPE{200e}

% \NOPE{200e}You can get probably get rid of these definitions\NOPE{200e}:
\newcommand\meta[1]{$\langle\hbox{#1}\rangle$}\NOPE{200e}
\newcommand\PaperTitle[1]{\textit{#1}''}\NOPE{200e}

\title{Statement on the Revision of \meta{Paper ID} \\NOPE{200e}
Based on the Referees' Report}\NOPE{200e}
\author{Author1 \and Author2 \and Author3}\NOPE{200e}
\date{\today}\NOPE{200e}

\NOPE{200e}\begin{document}\NOPE{200e}
\NOPE{200e}This statement concerns our revision of the \meta{Paper ID} paper\NOPE{200e},
\NOPE{200e}entitled \PaperTitle{\meta{Paper Title}}\NOPE{200e}, \NOPE{200e}based on the referees'\NOPE{200e}
\NOPE{200e}report\NOPE{200e}.

\Reviewer{\#1}\NOPE{200e}
\begin{response}{First comment.}\NOPE{200e}
Response to the first comment\NOPE{200e}.
\NOPE{200e}\end{response}\NOPE{200e}
\begin{response}{Second comment.}\NOPE{200e}
Response to the second comment\NOPE{200e}.
\NOPE{200e}\end{response}\NOPE{200e}

\NOPE{200e}\Reviewer{\#2}\NOPE{200e}
\NOPE{200e}\begin{response}{First comment.}\NOPE{200e}
\NOPE{200e}Response to the first comment\NOPE{200e}.
\NOPE{200e}\end{response}\NOPE{200e}\NOPE{200e}

\NOPE{200e}\end{document}


EDIT: here is the MEW again, cleaned of all the U+200E's, run it through pdflatex or xelatex and the error is completely different, related to the ~ in the definition of reviewer-comment~

\documentclass[10pt]{article}

% Allow Unicode input (alternatively, you can use XeLaTeX or LuaLaTeX)
% \usepackage[utf8]{inputenc}
\usepackage{microtype, xparse, tcolorbox}
\newenvironment{reviewer-comment}{}{}
\tcbuselibrary{skins}

\tcolorboxenvironment{reviewer-comment}{empty, left=1em, top=1ex,
bottom=1ex, borderline west={2pt}{0pt}{black!20},}
\ExplSyntaxOn
\NewDocumentEnvironment{response}{+m O{black!20}}{
\IfValueT{#1}{
\begin{reviewer-comment~}
\setlength\parindent{2em}
\noindent
\ttfamily #1
\end{reviewer-comment~}
}
\par\noindent\ignorespaces
}{\bigskip\par}

\NewDocumentCommand \Reviewer {m} {
}
\ExplSyntaxOff
\AtBeginDocument{\maketitle\thispagestyle{empty}\noindent}

% You can get probably get rid of these definitions:
\newcommand\meta[1]{$\langle\hbox{#1}\rangle$}
\newcommand\PaperTitle[1]{\textit{#1}''}

\title{Statement on the Revision of \meta{Paper ID} \\
Based on the Referees' Report}
\author{Author1 \and Author2 \and Author3}
\date{\today}

\begin{document}
This statement concerns our revision of the \meta{Paper ID} paper,
entitled \PaperTitle{\meta{Paper Title}}, based on the referees'
report.

\Reviewer{\#1}
\begin{response}{First comment.}
Response to the first comment.
\end{response}
\begin{response}{Second comment.}
Response to the second comment.
\end{response}

\Reviewer{\#2}
\begin{response}{First comment.}
Response to the first comment.
\end{response}

\end{document}


The error you get with the U+200E in the document is related to the error you get if you type

\documentclass{article} a


That single a will cause an error like

LaTeX Error: Missing \begin{document}.


as you are trying to typeset something in the preamble. pdflatex sees U+200E as an undefined char and complains. xelatex and lualatex klnows unicode and just sees it as a char (like a) tying to the typeset in the preamble.

The other error messages are probably artefacts because of the runmode your editor is using (ignoring errors).

• Is your script somewhere available? – albert Jun 8 '18 at 12:30
• @albert no, it is a just a personal perl script – daleif Jun 8 '18 at 12:45
• @albert basically you grab the unicode list from utf8enc.dfu and write a script that finds all chars outside of ascii plus that list. Of course, this will also hit Chinese etc, but right now we are jsut looking at latin-like scripts where there are strange chars that normally does not appear in a latin-like text. – daleif Jun 8 '18 at 12:49
• Interesting list I found one at in my distribution .../texmf-dist/tex/latex/base/utf8enc.dfu But still would you be willing to share it (as an as is script) with the community so others can benefit from it as well? – albert Jun 8 '18 at 12:58
• I understand. That is why I did write as well "as an as is script", but not every user will respect that with as a result questions, questions, ... – albert Jun 8 '18 at 13:26