0

This code works:

\documentclass{book}

\newenvironment{testenvironment}[1][] {\begin{quote}#1} {\end{quote}}

\begin{document}

\begin{testenvironment}[testargument] test text \end{testenvironment}

\end{document}

This code doesn't:

\documentclass{book}

\newenvironment{testenvironment}[1][] {\begin{quote}} {#1\end{quote}}

\begin{document}

\begin{testenvironment}[testargument] test text \end{testenvironment}

\end{document}

The only difference is whether #1 is written within the first vs. the second bracket of the \newenvironment command.

How do I pass the argument to the second bracket, to the content after the input?

Steeven
  • 1,407

1 Answers1

0

With more recent LaTeX-releases you can use \NewDocumentEnvironment instead of \newenvironment.
You may need to load the package xparse.

\documentclass{book}
\usepackage{graphicx}

\NewDocumentEnvironment{testenvironment}{O{}} {\begin{quote}} {#1\end{quote}}

\begin{document}

\begin{testenvironment}[testargument] test text \end{testenvironment}

\begin{testenvironment} test text \end{testenvironment}

\begin{testenvironment}[testargumentB] test text \end{testenvironment}

\end{document}

Ulrich Diez
  • 28,770