I'm working on some macros for recipe cards and I'm using the tabulary
package to limit the width of the ingredients list. I played around until I found something the behaved the way I wanted, then put it into a \newenvironment
. Then I ran into the issue in this question, so I changed \begin{tabulary}
and \end{tabulary}
to \tabulary
and \endtabulary
.
This worked fine in the \newenvironment
, but when I try to use these commands outside \newenvironment
, it sort of silently ignores the table and the rest of the document. Below is an example.
Why does this happen? Are \tabulary
and \endtabulary
allowed outside \newenvironment
?
\documentclass{article}
\usepackage{tabulary}
% Ingredients table environment
\newenvironment{ingredients}[0]{
\noindent\textbf{\textsf{Ingredients}}
\noindent
\tabulary{0.5\textwidth}{RL}}{
\endtabulary}
% Create an ingredient in the ingredients table
% First arg is the amount
% Second arg is the ingredient name
\newcommand{\ingredient}[2]{#1 & #2 \\}
\begin{document}
% Version 1: \begin{tabulary}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\noindent\textbf{\textsf{Ingredients}}
\noindent
\begin{tabulary}{0.5\textwidth}{RL}
\ingredient{1 can (10-3/4 oz)}{Condensed cream of chicken soup, undiluted}
\ingredient{1 cup}{Sour cream}
\ingredient{1}{Small onion, finely chopped}
\ingredient{1/4 cup}{Butter}
\ingredient{3/4 tsp}{Salt}
\ingredient{1/4 tsp}{Pepper}
\ingredient{1 package}{Frozen, cubed hash brown potatoes, thawed}
\ingredient{2 cups}{Shredded cheddar cheese}
\end{tabulary}
% Version 2: \tabulary in an environment
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{ingredients}
\ingredient{1 can (10-3/4 oz)}{Condensed cream of chicken soup, undiluted}
\ingredient{1 cup}{Sour cream}
\ingredient{1}{Small onion, finely chopped}
\ingredient{1/4 cup}{Butter}
\ingredient{3/4 tsp}{Salt}
\ingredient{1/4 tsp}{Pepper}
\ingredient{1 package}{Frozen, cubed hash brown potatoes, thawed}
\ingredient{2 cups}{Shredded cheddar cheese}
\end{ingredients}
% Version 3: \tabulary on its own
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\noindent\textbf{\textsf{Ingredients}}
\noindent
\tabulary{0.5\textwidth}{RL}
\ingredient{1 can (10-3/4 oz)}{Condensed cream of chicken soup, undiluted}
\ingredient{1 cup}{Sour cream}
\ingredient{1}{Small onion, finely chopped}
\ingredient{1/4 cup}{Butter}
\ingredient{3/4 tsp}{Salt}
\ingredient{1/4 tsp}{Pepper}
\ingredient{1 package}{Frozen, cubed hash brown potatoes, thawed}
\ingredient{2 cups}{Shredded cheddar cheese}
\endtabulary
This paragraph will not appear.
\end{document}
\tabulary
syntax is not supported in a document, why would you want to do that?\newenvironment
to try and iron out some kinks with my macros. When the macros weren't working the way I expected, I tried making a non-macro version to see whether I made a mistake "macroizing" them or if my LaTeX code I was macroizing was just wrong.tabulary
, suspecting this might not be allowed, but with my somewhat primitive (though hopefully growing) knowledge of TeX/LaTeX, I couldn't tell whether it was forbidden. Or supported. Maybe I was looking at outdated documentation, but I don't think so.\tabulary
at all in the user-facing documentation so there is no reason to say it isn't allowed. the\tabulary
in an environment definition feature is only indirectly documented as it's the same mechanism astabularx
(where this is better documented) for most latex environments you can not replace\begin{foo}..\end{foo}
by\foo..\endfoo
at the very least you lose the enviornment grouping by doing that. So you would not expect every package documentation to explicitly say you can not do this, it will not work in general.\newcommand
and\newenvironment
functioned more or less the way C preprocessor macros work, like fancy text substitution. It sounds like I still have a lot to read up on.