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.

I usually apply a \scalebox to resize things, but I always stumble upon the fact that I cannot simply include a \caption{...} in the \scalebox.

As an alternative to \scalebox, I found I may use \resizebox, but this macro also does not allow me to include \caption{...}'s.

Is there anyway to resize both the tabular and the table's caption?

share|improve this question
1  
Using scalebox in this way is going to lead to an inconsistent looking document. Changes to captions (size/font/colour, etc) can be made using the caption package –  cmhughes Jan 16 '13 at 16:21
    
@cmhughes So, does it mean there's no applicable macro for this case? Something like \scale_tabular_and_caption{...} \= There's no much concern about the looking of this \tabular + \caption and the rest of the document; I just want to have them both resized. –  Rubens Jan 16 '13 at 16:26

2 Answers 2

up vote 12 down vote accepted

Here is working example of resizing table together with caption.

\documentclass{article}
\usepackage{graphicx}
\begin{document}

\begin{table}[htbp]
  \centering
  \resizebox{0.5\textwidth}{!}{\begin{minipage}{\textwidth}
        \caption{Table caption}
        \begin{tabular}{|c|c|c|c|}
          \hline
          $t_0~(MeV\cdot fm^3 ) $ & $t_3~(MeV\cdot fm^6)$ & $v_0/\mu~(MeV\cdot fm)$ & $1/\mu~(fm)$\\
          \hline
          $$ -497.726 & $17270$ & $-166.924$ & $0.45979$\\
          \hline
        \end{tabular}
      \end{minipage}}
\end{table}

\end{document}

FIXED: Example was edited. Thanks!

share|improve this answer
3  
+1 it might be worth mentioning that the same approach works with other boxes too such as vbox, parbox, etc. You can also just use \centering rather than \begin{centering}...\end{centering}; finally- table captions should go on top :) –  cmhughes Jan 16 '13 at 17:26
3  
Why figure? Use table and the simple \caption command. There are spurious spaces: one after \resizebox{.5\hsize}{ (and \textwidth would be better than \hsize), one after \end{minipage}. –  egreg Jan 16 '13 at 17:30
    
Thank you all for the tips! –  Rubens Jan 16 '13 at 18:33

How to scale/resize a table/tabular inside a minipage

This question is the first one to pop up when searching for: latex scale table in minipage. Likewise queries such as rescale table in minipage or resize table in minipage end up at this answer too.

I was personally also searching for this and couldn't find an answer anywhere. However, I've found the solution. Judging by the amount of views of this question, I guess it'll be extremely helpful to some people to post it here.

So to resize/rescale a table inside a minipage, do the following:

Include the adjustbox package in your preamble:

\usepackage{adjustbox}
\usepackage{caption}    % only if you want to add a caption to your table

Now you can rescale your tabular or table environment as follows:

\begin{minipage}[t]{0.5\textwidth}                          % minipage spans half the textwidth
\begin{center}
  \begin{adjustbox}{center, width=\columnwidth-10pt}        % can also use \linewidth or sth. else

      % your table ..                                       % put your table here

  \end{adjustbox}
  \captionof{table}{Your caption goes here}                 % add a caption if you want
\end{center}
\end{minipage}

Note that I've used the parameter center (to center the content). Somehow I still needed \begin{center} .. \end{center} to get everything properly aligned. Also note I used width=\columnwidth-10pt which scales both the width and height of the table simultaneously.

To use other scaling, simply use another width= for your adjustbox. This works just as normal width parameters.

Hope that helped some people out :)

You can find additional documentation of adjustbox here: adjustbox documentation.

Edit: A MWE

A minimal working example (MWE) would be the following:

\documentclass{article}
\usepackage{adjustbox}
\usepackage{caption}    % only if you want to add a caption to your table

\begin{document}
\noindent                                                   % remove any indentation
\begin{minipage}[t]{0.5\textwidth}                          % minipage spans half the textwidth
    \begin{center}
        \begin{adjustbox}{center, width=\columnwidth-10pt}  % can also use \linewidth or sth. else

            \begin{tabular}{c | c}                          % little tabular example
                Column 1 & Column 2 \\
                \hline
                1 & 2
            \end{tabular}

        \end{adjustbox}
        \captionof{table}{Your caption goes here}           % add a caption if you want
    \end{center}
\end{minipage}
\end{document}
share|improve this answer
    
Please augment your code snippets to create a compilable MWE. –  Mico Jan 28 at 20:56
    
Why are you using \columnwidth rather than \linewidth to scale the adjustbox environment? Why are you subtracting 10pt from the width of the minipage? If you set the width of the adjustbox environment to \linewidth, there would be no need to employ a center environment and thus no need to deal with the (presumably unwanted) extra vertical whitespace that's inserted by the center environment. –  Mico Jan 28 at 21:02
    
@Mico: Because my application happens to be two minipages next to each other. Please edit yourself if you feel the need to improve. For me it worked perfectly with the center environment so I put it in to illustrate a working example for any use-case of the minipage environment. Not just for the case when you don't need to deal with white spaces. –  Jean-Paul Jan 28 at 21:04
    
@Mico: Done as requested. –  Jean-Paul Jan 28 at 21:07
    
It's your posting, so you should provide all information that's needed for people to understand the stylistic, layout, and other choices you made. Otherwise, one or more of the choices you make, implicitly or explicitly, risk coming across as being random and/or unmotivated. Two suggestions for improving your code: (i) if you're going to place two minipages side by side, you should preface the first one with \noindent; (ii) use \centering instead of \begin{center} and \end{center} to avoid the (presumably unwanted) extra whitespace generated by the center environment. –  Mico Jan 28 at 21:11

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.