I would like to define a new environment with conditions in my template file. My environment consists in a lign of header filled by a title (given at the environment in an argument) and then at the next line the body of the text provided between the \begin{...} and \end{...}
More specifically I would like, given an argument of the environment, to put the title + body in a tabular to handle its position. The argument is a number, if the number equals 0, the title + body are normally defined. On the other hand, if the number differs from 0, the title+body are defined in a tabular with a unique cell that contains both.
Below is a solution that actually works but I face error messages (though it compiles) :
\newenvironment{test}[2][0]
{\noindent\ifthenelse{ \equal{#1}{0} }{
{#2}
}{
\begin{tabular}{|p{0.9\textwidth}}
{#2}\\
}}
{
\\
\end{tabular}
}
I used the package ifthen, and I think that is the only one required for this.
Some cases of utilisation below :
\begin{test}[0]{Title}
Body of the text without tabular\\
\end{test}
\begin{test}[1]{Title}
Body of the text with tabular\\
\end{test}
The output of this code is the following :
So the code here actually works but I have several errors like "Extra }, or forgotten \endgroup.". I would like to know if someone could find my error here?
NB : as you may understand from this example, I ultimately try to put a defined number of vertical side lines on the left of my text. If you have a better approach than the one I chose, I am open to any suggestion!