Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In a book I'm typesetting, I want the tabular environment to be in footnote size and the other body of the book to be in normalsize font. To do this, I've tried something like the following:

‎‎‎‎‎‎‎\re‎newenvironment‎{‎‎tabular‎‎}[1][t‎]{\footnotesize‎‎‎‎‎
\begin{tabular}‎
‎‎‎‎‎‎‎‎‎‎‎‎‎[#1]}{‎‎‎‎\end{tabular}‎\normalsize‎‎‎‎}‎

But I get the following error:

! TeX capacity exceeded, sorry [save size=50000]. 
 <to be read again> 
               \relax 
 l.72 \centering\begin{tabular}{
                           cccccc}

By the way, I'm using the tabular as below:

\begin{‎table}[t]‎
\caption{Title}\label{tab1‎}‎‎
‎\centering‎‎‎‎‎\begin{‎tabular}{c‎c‎‎‎‎‎‎c‎‎c‎‎‎‎cc‎‎}‎‎‎
‎....
‎‎‎\end{‎tabular}‎
\end{‎table}‎‎

Have I done something wrong here?

Edit on December 28th (another question):

In the following code, if I want also to add a \centering command, where should I put it? I have put it before and after the \footnotesize but it doesn't work!

\let\oldtabular\tabular
\let\endoldtabular\endtabular
\renewenvironment{tabular}{\bgroup\footnotesize\oldtabular}%
                          {\endoldtabular\egroup}
share|improve this question
    
Could you please add the error messages to the question? –  Caramdir Aug 31 '10 at 20:01
2  
Don't do such adjustments: you'll be sorry when you'll need a plain tabular environment. The \centering and \footnotesize commands belong to the table environment and not to tabular. Use a new environment, if you prefer. –  egreg Dec 28 '11 at 0:23
4  
Please don't use edits to ask a follow-up question; instead, ask a new question and provide a link to the original question for the context. –  lockstep Dec 28 '11 at 0:29
add comment

3 Answers

up vote 15 down vote accepted

A better approach is to define a new tabular environment with your own customizations

\newenvironment{smalltabular}{\footnotesize\tabular}{\endtabular}

And then use smalltabular instead of tabular. A few things to note:

  • In the definition of a new environment, instead of \begin{tabular} and \end{tabular} it's enough to say \tabular and \endtabular.
  • You dont need to register any arguments for smalltabular, because the last command in it's definition (i.e. \tabular) will already look for and process any arguments appropriately.

If for some reason you really want to redefine the tabular environment, you first need to save it's old definition and then redefine it. For example

\let\oldtabular\tabular
\let\endoldtabular\endtabular
\renewenvironment{tabular}{\footnotesize\oldtabular}{\endoldtabular}
share|improve this answer
    
Thanks Juan, your reply is completely understandable. Thanks everybody. –  Vahid Damanafshan Aug 31 '10 at 21:35
    
Your method for redefining the tabular environment is cleaner than my suggestion. As for "some reason" to redefine: I like to implement general changes (changing the fontsize for tabular) in the preamble rather than to replace every "tabular" with "smalltabular" in the document body. –  lockstep Aug 31 '10 at 21:59
    
@Vahid, if you like the answer feel free to mark it as accepted ;) –  Juan A. Navarro Aug 31 '10 at 22:51
1  
The \bgroup and \egroup are redundant, as any environment forms a group by itself. –  egreg Dec 27 '11 at 22:07
2  
And \usepackage{etoolbox} followed by \preto\tabular{\footnotesize} is even easier. :) –  egreg Dec 29 '11 at 16:45
show 1 more comment

When you use \renewenvironment, it doesn't expand the new definition until it is used. So in your case, when you call it, it tries to expand the new tabular environment and substitutes the \begin{tabular}, you've included in that one, leading to another one, and so on, leading to an infinite loop.

In general you cannot define an environment or command in terms of itself, unless you're very very careful to ensure that's its recursively well-grounded.

(EDIT: Sorry to duplicate lockstep; we were answering at the same time.)

share|improve this answer
1  
Thanks for your complete reply. What do you mean exactly by "unless you're very very careful to ensure that's its recursively well-grounded."? –  Vahid Damanafshan Aug 31 '10 at 21:05
add comment

Using the \tabular macro inside a redefinition of the same macro will produce an infinite loop. Try the following:

\makeatletter
\renewcommand{\tabular}{\let\@halignto\@empty\footnotesize\@tabular}
\makeatother
share|improve this answer
    
What a interesting method! can u please explain more about that? what is the role of @halignto and @empty? –  Vahid Damanafshan Aug 31 '10 at 21:01
2  
I don't know their roles. ;-) I simply looked up the original definition of \tabular in the article class (using \show\tabular), added \footnotesize in a location that seemed plausible and tested the resulting code. –  lockstep Aug 31 '10 at 21:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.