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'm having trouble with the xparse package's environment creating commands. What I'd like to do in the end is write my own list environment. The toy example below shows my current problem: the list shows up, but some extra text is getting appended during the closing of the environment. I "fixed" it by using the \newenvironment command, but I was hoping to use the argument processing options that xparse provides.

In the cljlists.sty package:

\NewDocumentEnvironment{xparselist}{}{BEGIN!\begin{itemize}}{\end{itemize}END!}
\newenvironment{newlist}{BEGIN!\begin{itemize}}{\end{itemize}END!}

In the document:

\subparagraph*[short]{Second Sub-Paragraph}
text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text
\begin{newlist}
\item item
\end{newlist}
\begin{xparselist}{mandatory}
\item item
\end{xparselist}

This outputs: (sorry the image got chopped for being new, but about like this...)

Second Sub-Paragraph text...text BEGIN!

  • item

END!BEGIN!

  • item

END! shortSecond Sub-Paragraph

I'm not sure why the arguments provided to \subparagraph are being used by the blahblahblah environment when it closes. I have redefined \subparagraph using xparse's \DeclareDocumentCommand. I don't have this problem when I declare another command using xparse, however. Have I missed something important in the documentation?


EDIT: here's complete minimal copy of the code which reproduces the problem, including requests from the comments.

The problem should be more apparent now that I can attach photos. The list environment I created using xparse, is typesetting some text immediately after the environment closes, which appears to come from the arguments I provide to the subparagraph command.

Document:

\documentclass{article}
\usepackage{toylists}

\begin{document}
\subparagraph{title}
text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text
\begin{newenvlist}
\item item
\end{newenvlist}
\begin{xparselist}
\item item
\end{xparselist}
\end{document}

Package:

\ProvidesPackage{toylists}[2011/03/08 xparse list example]

\NeedsTeXFormat{LaTeX2e}
\RequirePackage{xparse}

\DeclareDocumentCommand{\subparagraph}{s o m}{\textit{#3}}

\NewDocumentEnvironment{xparselist}{}{%
\begin{itemize}}{%
\end{itemize}}

\newenvironment{newenvlist}{%
\begin{itemize}}{%
\end{itemize}}

Output:

enter image description here

share|improve this question
2  
Possibly there's a bug in xparse, but to be sure I could do with a full example (starting \documentclass and ending \end{doccument}): I'm a bit lost with the description of what you've actually tried. –  Joseph Wright Mar 4 '11 at 21:25
    
With your updated example, I don't really see what is up. You seem to have missed out % characters at the end of lines, which are used to prevent spurious spaces appearing. However, that does not just apply to xparse. –  Joseph Wright Mar 4 '11 at 22:21
    
@Joseph: would it make sense to say "use \ExplSyntaxOn...\ExplSyntaxOff to avoid worrying about spaces" in this case ? –  Bruno Le Floch Mar 5 '11 at 15:52
1  
@cljacobs this displays fine for me. What version of xparse do you have? Put \listfiles in your preamble and have a look at the log file to find out... –  Seamus Mar 8 '11 at 16:20
1  
@cljacobs: Any chance of a full log? Your problem is 'works for me' for both @seamus and for me. –  Joseph Wright Mar 13 '11 at 14:14
show 6 more comments

closed as too localized by Joseph Wright Mar 22 '11 at 13:41

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.

Browse other questions tagged or ask your own question.