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.

Is is possible to resize a table imported from another table without having to modify the LaTeX code in the file from which the table is imported? I was thinking of something like:

\documentclass[english]{article}
\usepackage{babel}
\usepackage{graphicx}
\usepackage[margin = 1.5 cm, tmargin=1.5 cm]{geometry} 

\begin{document}

\scalebox{0.5}{%
    \input{DS}
  }%

\end{document}

The table in the file DS.tex looks like the following:

\begin{table}[!htpb]
\centering
\begin{tabular}{ccc}
% ...
\end{tabular}
\end{table}

I got as expected the error : ! LaTeX Error: Not in outer par mode.

I would like to know whether it is possible to resize the table in DS file without modifying it.

share|improve this question
    
Yes, did you try it? If you have an error then ask about that error (and supply a test file that demonstrates the problem) –  David Carlisle Mar 23 at 11:41
    
Note you are missing a % after the input, and the file needs top contain a tabular not a table environment. –  David Carlisle Mar 23 at 12:25

1 Answer 1

up vote 5 down vote accepted

A floating environment (table, figure, ...) cannot put into an \hbox or \scalebox that internally uses \hbox. However the environment can be redefined locally:

\scalebox{0.5}{%
    \renewenvironment{table}[1][]{\ignorespaces}{\unskip}%
    \input{DS}%
    \unskip
}

\ignorespaces and \unskip remove spaces by line ends in the file DS.tex that does matter in horizontal mode. An alternative is using \endlinechar=-1\relax, but this depends on the contents of the tabular environment, because some line ends might not be unwanted (e.g. space between words).

The floating environment can be inserted afterwards, e.g.:

\begin{table}
  \centering
  \caption{Table caption}
  \scalebox{...}{...}
\end{table}
share|improve this answer

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.