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.

I am using the environ package to collect the body of an environment to be used later. It appears that the environenvironment gobbles the trailing space. For example,

\documentclass{article}

\usepackage{environ}

\NewEnviron{myenviron}{\BODY}
\begin{document}
A \begin{myenviron}B\end{myenviron} C

X\begin{myenviron}Y\end{myenviron}Z
\end{document}

gives me A BC and XYZ, but I would like A B C and XYZ. What is the proper way to get the trailing space back?

I just looked at the source code and the answer is on line 7

\environfinalcode{\ignorespacesafterend}

so I can fix the problem with \environfinalcode{}, but I would prefer a less global change.

share|improve this question

1 Answer 1

up vote 6 down vote accepted

The \environfinalcode is executed if not overridden explicitly with the final optional argument.

\documentclass{article}

\usepackage{environ}

\NewEnviron{myenviron}{\BODY}[]

\begin{document}
A \begin{myenviron}B\end{myenviron} C

X\begin{myenviron}Y\end{myenviron}Z
\end{document}

enter image description here

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.