1

Is there a way to rescale a table, not from within the table environment?

I know that scaling can be changed from within the table environment, as in this example. But I would like it to be from outside. That is, I am looking for a command to come before \begin{table}. Any suggestions?

Martin Scharrer
  • 262,582
splinter
  • 163
  • 2
    It is not recommended to rescale a table, as it often makes it unreadable. It's better to play with the font size or the value of \tabcolsep. – Bernard Apr 04 '17 at 23:06
  • I am aware of that, however, I must do it this way as I am inputting the table as an auxillary file which cannot be changed. – splinter Apr 04 '17 at 23:18
  • 2
    since the table environment is a float, it is not possible to wrap it in another environment for the purposes of scaling. that would have to be done inside the table environment. the only possible approach i can think of would be to redefine the table environment (to be used only temporarily) to create a wrapper that calls the "oldtable" with the scaling code inside of it. (i'm not competent enough to try to code that.) – barbara beeton Apr 05 '17 at 00:48

1 Answers1

3

As barbara beeton already said, you can't wrap a float like table in a box and then scale it, your need to use its content only. However, you can redefine table to apply the scaling code automatically to its content as shown below. Note that this non-optimal as you should scale text to much in LaTeX and the alignment of caption and actual table (the tabular) can be disturbed.

\documentclass{article}


\usepackage{lipsum}% for example text only
\usepackage{adjustbox}% for the scaling

\let\oldtable\table
\let\endoldtable\endtable

\renewenvironment{table}[1][]%
{\oldtable[#1]\adjustbox{varwidth=\linewidth,scale=3,center}\bgroup}
{\egroup\endoldtable}

\begin{document}

\lipsum% insert example text

    \begin{table}[hp]
        \centering
        \caption{My table}\label{fig:figure1}
        \begin{tabular}{lll}
          a & b & c \\
          a & b & c \\
        \end{tabular}
    \end{table}

\lipsum% insert example text


\end{document}
Martin Scharrer
  • 262,582