# Trouble with \begin{tabulary} vs. \tabulary

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}


• the \tabulary syntax is not supported in a document, why would you want to do that? – David Carlisle Dec 10 '17 at 20:01
• I was using it outside \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. – Nick Dec 10 '17 at 20:38
• Also, I tried reading the documentation for 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. – Nick Dec 10 '17 at 20:52
• actually tabulary doesn't mention \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 as tabularx (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. – David Carlisle Dec 10 '17 at 21:01
• That seems to be getting deeper into the theory of LaTeX than I was familiar with. I wasn't aware environments created any special kind of grouping--I was thinking \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. – Nick Dec 10 '17 at 23:09

Like many other environments, tabulary needs to grab all the text to the end environment so that it can do trial runs to find the column width.
The \tabulary form is (as documented) a special construct for use in another environment definition that allows tabulary to detect the outer environment name so that it can grab as far as \end{ingredients} there is no reason to use \tabulary in a document, and as you observe, it doesn't work.