Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

When I try to compile the MWE below with xelatex, I get the following:

*geometry* detected driver: pdftex
)
*

The * seems to be a prompt: pressing ENTER gives

*
(Please type a command or say `\end')
*
(Please type a command or say `\end')
*
(Please type a command or say `\end')
*

The .log file isn't useful. Leaving aside whatever the actual error in my document is, I don't understand what's happening: why is LaTeX pausing in this fashion without emitting any error?

MWE:

\documentclass[a4paper,10pt]{article}
\usepackage[landscape,hmargin={1.2cm,1cm},vmargin=1cm,footskip=7mm]{geometry}
\usepackage[no-math]{fontspec}
\usepackage[T1]{fontenc}

\makeatletter

\begingroup
\lccode`\~`\\
\lowercase{\endgroup
\def\vb{%
\par
\parindent\z@
\parskip1\baselineskip plus 2pt\relax
\let\do\@makeother\dospecials%
\let\@xobeysp\space
\catcode`\ \active
\catcode`\\\active
\let~\scanendvb
}}
\def\scanendvb#1#2#3#4#5#6#7{%
\def\x{#1#2#3#4#5#6#7}%
\ifx\x\endvbstr
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
{\end{vb}}{\char`\\#1#2#3#4#5#6#7}}

\edef\endvbstr{end\string{vb\string}}

\makeatother
\def\endvb{\par}

\newenvironment{almsinp}{\begin{minipage}[t]{0.5\textwidth}\begin{vb}}{\end{vb}\end{minipage}}

\begin{document}
\begin{almsinp}
Definition 2.1.2.
A _metric space_ M = (A, d) consists of a non-empty set A together with a map d : A\times A -> \bfR such that:
    (M1a) d(x, y)\geq 0 for all x, y in A.
    (M1b) d(x, y) = 0 <=>  x = y  for all x, y in A.
    (M2) d(x, y) = d(y, x) for all x, y in A.
    (M3) d(x, y)+d(y, z)\geq d(x, z) for all x, y, z in A.
The elements of A are called the _points_ of the metric space M, and d is called a _metric_ on A. We sometimes also call d the _metric_ of M.
\end{almsinp}
\end{document}
share|improve this question
3  
You can't use the vb environment as argument to other commands. It's a limitation holding for all "verbatim-type" environments. –  egreg Dec 8 '12 at 15:20
2  
Looks like you are reading verbatim and failing to close it correctly :-) As a result LaTeX is getting to the end of the file and waiting for more input, which is what TeX does when it has not reached an error or something to end the run (run TeX interactively to see this). –  Joseph Wright Dec 8 '12 at 15:21
    
egreg's answer led me to an explanation of the phenomenon at tex.ac.uk/cgi-bin/texfaq2html?label=verbwithin –  Mohan Dec 8 '12 at 15:27

1 Answer 1

up vote 3 down vote accepted

You can't use the vb environment in the argument to another command, as it's always the case with "verbatim-like" commands. I suggest you to add an optional argument to vb and change its definition so it uses a minipage. But you have to realize that this will prohibit page breaks.

\documentclass[a4paper,10pt]{article}
\usepackage[landscape,hmargin={1.2cm,1cm},vmargin=1cm,footskip=7mm]{geometry}
\usepackage[no-math]{fontspec}

\makeatletter

\begingroup
\lccode`\~`\\
\catcode`!\active
\lccode`!=`\^^M
\lowercase{\endgroup
\newcommand\vb[1][\textwidth]{%
\par\noindent\minipage[t]{#1}
\parskip1\baselineskip plus 2pt\relax
\let\do\@makeother\dospecials%
\let\@xobeysp\space
\catcode`\ \active
\catcode`\\\active
\catcode`\^^M\active
\def!{\par\leavevmode}
\let~\scanendvb
}}
\def\scanendvb#1#2#3#4#5#6#7{%
\def\x{#1#2#3#4#5#6#7}%
\ifx\x\endvbstr
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
{\end{vb}}{\char`\\#1#2#3#4#5#6#7}}

\edef\endvbstr{end\string{vb\string}}

\makeatother
\def\endvb{\endminipage}

\begin{document}
\begin{vb}[.5\textwidth]
Definition 2.1.2.
A _metric space_ M = (A, d) consists of a non-empty set A together with a map d : A\times A -> \bfR such that:
    (M1a) d(x, y)\geq 0 for all x, y in A.
    (M1b) d(x, y) = 0 <=>  x = y  for all x, y in A.
    (M2) d(x, y) = d(y, x) for all x, y in A.
    (M3) d(x, y)+d(y, z)\geq d(x, z) for all x, y, z in A.
The elements of A are called the _points_ of the metric space M, and d is called a _metric_ on A. We sometimes also call d the _metric_ of M.
\end{vb}
\end{document}

By the way, this incorporates some changes so as to get line breaks at each end-of-line.

Note that loading fontenc when using fontspec is generally not necessary.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.