I'm having problems with an environment definition. Using the xparse and etoolbox packages, I have created the environment syriacpoem in my .sty file. It is defined as
%%%%%% \DeclareDocumentEnvironment{syriacpoem}{so}{% \ifbool{...@kashpoem}{\begin{syrjust}}{}% \begin{syriac}% \ifstrequal{#2}{estr}{\estrfont}{}% \ifstrequal{#2}{serto}{\sertofont}{}% \ifstrequal{#2}{madnha}{\madnhafont}{}% \ifstrequal{#2}{east}{\madnhafont}{}% \ifstrequal{#2}{estrangelo}{\estrfont}{}% \ifstrequal{#2}{estrangela}{\estrfont}{}% \IfBooleanTF #1 {\begin{traditionalpoem*}}{\begin{traditionalpoem}}}{% \IfBooleanTF #1 {\end{traditionalpoem*}}{\end{traditionalpoem}}\end{syriac}% \ifbool{...@kashpoem}{\end{syrjust}}{}} %%%%%% The boolean x...@kashpoem is true if word-stretching justification is required. The environment syrjust provides that justification using a version of Jonathan Kew and Fr Michael Gilmary's implementation with interchartoks shown on this list. The syriac environment is from polyglossia, ensuring RTL and a Syriac font, and it is followed by optional font switches for other Syriac fonts. Then either the starred or unstarred version of bidipoem's traditionalpoem environment is turned on depending on the presence or absence of a star in the document command. The end of environment closes all these nested environments in order. This new environment works as expected in normal tests. However, as I came to document it, I wanted to give an example in a framed float in my package documentation. However, the new environment breaks inside the float. My framed box uses the fancybox package and is defined as %%%%%% \newenvironment{example}[1]% {\begin{figure}[h]\begin{center}\begin{Sbox}\begin{minipage}{#1}}% {\end{minipage}\end{Sbox}\ovalbox{\TheSbox}\end{center}\end{figure}} %%%%%% Obviously, something in the environment is upsetting my example box. If I replace my syriacpoem environment with the nested environments it calls, it works perfectly. So, there's nothing wrong with what the environment does, just in how it does it. The lengthy section of the log dealing with this is below. Can anyone suggest how to fix this? Thanks, Gareth. Log extract follows: ! Missing number, treated as zero. <to be read again> \group_end: l.314 ^^I\end{syriacpoem} A number should have been here; I inserted `0'. (If you can't figure out why I needed to see a number, look up `weird error' in the index to The TeXbook.) ! LaTeX Error: \begin{traditionalpoem*} on input line 305 ended by \end{traditi onalpoem}. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.314 ^^I\end{syriacpoem} Your command was ignored. Type I <command> <return> to replace it with another command, or <return> to continue without it. ! Extra }, or forgotten \endgroup. \endminipage ...pagefalse \co...@endgroup \egroup \...@rtl \endL \fi \egroup ... l.316 ^^I\end{example} I've deleted a group-closing symbol because it seems to be spurious, as in `$x}$'. But perhaps the } is legitimate and you forgot something else, as in `\hbox{$x}'. In such cases the way to recover is to insert both the forgotten and the deleted material, e.g., by typing `I$}'. ! Extra }, or forgotten \endgroup. \endminipage ...\egroup \...@rtl \endL \fi \egroup \egroup \expandafter \...@iii... l.316 ^^I\end{example} I've deleted a group-closing symbol because it seems to be spurious, as in `$x}$'. But perhaps the } is legitimate and you forgot something else, as in `\hbox{$x}'. In such cases the way to recover is to insert both the forgotten and the deleted material, e.g., by typing `I$}'. ! Extra }, or forgotten \endgroup. \endminipage ......@rtl \endL \fi \egroup \egroup \expandafter \...@iiiparbox \... l.316 ^^I\end{example} I've deleted a group-closing symbol because it seems to be spurious, as in `$x}$'. But perhaps the } is legitimate and you forgot something else, as in `\hbox{$x}'. In such cases the way to recover is to insert both the forgotten and the deleted material, e.g., by typing `I$}'. ! LaTeX Error: Misplaced \endSbox! Should be in LR mode. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.316 ^^I\end{example} You're in trouble here. Try typing <return> to proceed. If that doesn't work, type X <return> to quit. ! LaTeX Error: \begin{minipage} on input line 304 ended by \end{Sbox}. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.316 ^^I\end{example} Your command was ignored. Type I <command> <return> to replace it with another command, or <return> to continue without it. ! Missing } inserted. <inserted text> } l.316 ^^I\end{example} I've inserted something that you may have forgotten. (See the <inserted text> above.) With luck, this will get me unwedged. But if you really didn't forget anything, try typing `2' now; then my insertion and my current dilemma will both disappear. ! Missing } inserted. <inserted text> } l.316 ^^I\end{example} I've inserted something that you may have forgotten. (See the <inserted text> above.) With luck, this will get me unwedged. But if you really didn't forget anything, try typing `2' now; then my insertion and my current dilemma will both disappear. ! LaTeX Error: \TheSbox is empty!. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.316 ^^I\end{example} You're in trouble here. Try typing <return> to proceed. If that doesn't work, type X <return> to quit. ! LaTeX Error: Something's wrong--perhaps a missing \item. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.316 ^^I\end{example} Try typing <return> to proceed. If that doesn't work, type X <return> to quit. ! LaTeX Error: Something's wrong--perhaps a missing \item. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.316 ^^I\end{example} Try typing <return> to proceed. If that doesn't work, type X <return> to quit. ! LaTeX Error: \begin{Sbox} on input line 304 ended by \end{center}. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.316 ^^I\end{example} Your command was ignored. Type I <command> <return> to replace it with another command, or <return> to continue without it. ! Missing } inserted. <inserted text> } l.316 ^^I\end{example} I've inserted something that you may have forgotten. (See the <inserted text> above.) With luck, this will get me unwedged. But if you really didn't forget anything, try typing `2' now; then my insertion and my current dilemma will both disappear. ! Extra }, or forgotten \endgroup. \...@endfloatbox ...pagefalse \ou...@nobreak \egroup \co...@endbox l.316 ^^I\end{example} I've deleted a group-closing symbol because it seems to be spurious, as in `$x}$'. But perhaps the } is legitimate and you forgot something else, as in `\hbox{$x}'. In such cases the way to recover is to insert both the forgotten and the deleted material, e.g., by typing `I$}'. ! LaTeX Error: \begin{figure} on input line 304 ended by \end{example}. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.316 ^^I\end{example} Your command was ignored. Type I <command> <return> to replace it with another command, or <return> to continue without it. ! Missing } inserted. <inserted text> } l.316 ^^I\end{example} I've inserted something that you may have forgotten. (See the <inserted text> above.) With luck, this will get me unwedged. But if you really didn't forget anything, try typing `2' now; then my insertion and my current dilemma will both disappear. -------------------------------------------------- Subscriptions, Archive, and List information, etc.: http://tug.org/mailman/listinfo/xetex