I've created a custom environment for displaying code examples in a beamer
presentation (for an introductory LaTeX couse no less), but compiling my "old" code suddenly results in an error. According to the old log file the version is xparse 2011/10/09 v2900
. The definition is (slightly cleaned for brevity):
\NewDocumentEnvironment{codeblock}{o}{
\IfNoValueTF{#1}
{\begin{exampleblock}{Code}}
{\begin{exampleblock}{Code: #1}}}
{\end{exampleblock}}
and the error is
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! LaTeX error: "xparse/expandable-ending-optional"
!
! Argument specification for expandable command ends with optional argument.
!
! See the LaTeX3 documentation for further information.
!
! For immediate help type H <return>.
!...............................................
when compiled using xparse 2012/08/29 v4160
on my up-to-date TeX Live 2012 installation. First step in debugging this problem is to create a MWE, but this results in a quite separate error. The code
\documentclass{article}
\usepackage{xparse}
\NewDocumentEnvironment{xptest}{o}{\begin{center}
\IfNoValueTF{#1}{\textbf{Test}}{\textbf{Test: #1}}\par}
{\end{center}}
\begin{document}
\begin{xptest}[Arg]
World
\end{xptest}
\begin{xptest}
World
\end{xptest}
\end{document}
does not yield the expected result (i.e. two pieces of centered text with a bold first line) but this:
I've read the documentation for my currently installed version of xparse
, but this makes no mention of any limitation regarding terminating optional arguments. Is this a regression or expected but yet undocumented behaviour?