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'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:

Unexpected result

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?

share|improve this question

closed as too localized by cgnieder, percusse, diabonas, lockstep, Claudio Fiandrino Sep 13 '12 at 10:27

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
This is already fixed in the SVN and should be on CTAN in a few days. –  cgnieder Sep 3 '12 at 17:13
    
Thanks. I'll wait a few days, try again and hope that the fixed version will allow terminating optional arguments. –  spet Sep 3 '12 at 17:39