5

I use \setstretch{1.3} to increase line spacing. It does increase line spacing in tabular environments as well, which is what I want. But if the tabular is in a figure environment, line spacing is back down to 1.

This acrticle: baselinestretch vs. setspace suggests setting \renewcommand{\arraystretch}{1.2}, but it will affect all my tabulars, regardless of figure environments.

Is there a way to force \setstretch for figure environments as well?

EDIT: Here is a MWE:

\documentclass{article}
\usepackage{lipsum}
\usepackage{setspace}

\begin{document}
\setstretch{1.3}

\lipsum[1]

\bigskip
\begin{tabular}{ r | r | r }
         7168 &       1623040  &  28.30    \\
        14336 &       3228672  &  28.15    \\
        28160 &       6439936  &  28.59    \\
        56320 &      12862464  &  28.55    \\
       110592 &      25707520  &  29.06    \\
\end{tabular}

\begin{figure}[h]
\begin{tabular}{ r | r | r }
         7168 &       1623040  &  28.30    \\
        14336 &       3228672  &  28.15    \\
        28160 &       6439936  &  28.59    \\
        56320 &      12862464  &  28.55    \\
       110592 &      25707520  &  29.06    \\
\end{tabular}
\end{figure}

\end{document}
3
  • 1
    You can issue \renewcommand{\arraystretch}{1.3} after \begin{figure}, so it will be localized there. Could you please add a minimal working example (MWE)?
    – egreg
    Mar 19 '14 at 12:49
  • Thanks! But is there no solution where I can adjust line spacing for figure environments only once at the beginnging of the document?
    – cxxl
    Mar 19 '14 at 12:53
  • That's why I asked for a minimal example.
    – egreg
    Mar 19 '14 at 12:53
4

If you want to do this inside all of your figure environments, use etoolbox and its \AtBeginEnvironment macro

Put the following in your preamble:

\usepackage{etoolbox}
\AtBeginEnvironment{figure}{\renewcommand\arraystretch{1.3}}{}{}

Full code:

\documentclass{article}
\usepackage{lipsum}
\usepackage{setspace}
\usepackage{etoolbox}
\AtBeginEnvironment{figure}{\renewcommand\arraystretch{1.3}}{}{}

\begin{document}
\setstretch{1.3}

\lipsum[1]

\bigskip
\noindent
\begin{tabular}{ r | r | r }
         7168 &       1623040  &  28.30    \\
        14336 &       3228672  &  28.15    \\
        28160 &       6439936  &  28.59    \\
        56320 &      12862464  &  28.55    \\
       110592 &      25707520  &  29.06    \\
\end{tabular}

\begin{figure}[ht]
\begin{tabular}{ r | r | r }
         7168 &       1623040  &  28.30    \\
        14336 &       3228672  &  28.15    \\
        28160 &       6439936  &  28.59    \\
        56320 &      12862464  &  28.55    \\
       110592 &      25707520  &  29.06    \\
\end{tabular}
\end{figure}

\end{document}

enter image description here

1
  • Great! That works nicely.
    – cxxl
    Mar 19 '14 at 14:45
2

Here, I create myfigure environment to do what you ask.

\documentclass{article}
\usepackage{lipsum}
\usepackage{setspace}
\newenvironment{myfigure}[1][htbp]{\figure[#1]\renewcommand\arraystretch{1.3}}
{\endfigure}

\begin{document}
\setstretch{1.3}

\lipsum[1]

\bigskip
\begin{tabular}{ r | r | r }
         7168 &       1623040  &  28.30    \\
        14336 &       3228672  &  28.15    \\
        28160 &       6439936  &  28.59    \\
        56320 &      12862464  &  28.55    \\
       110592 &      25707520  &  29.06    \\
\end{tabular}

\begin{myfigure}[ht]
\begin{tabular}{ r | r | r }
         7168 &       1623040  &  28.30    \\
        14336 &       3228672  &  28.15    \\
        28160 &       6439936  &  28.59    \\
        56320 &      12862464  &  28.55    \\
       110592 &      25707520  &  29.06    \\
\end{tabular}
\end{myfigure}

\end{document}

However, if you wish to actually redefine the figure environment,

\documentclass{article}
\usepackage{lipsum}
\usepackage{setspace}
\let\svfigure\figure
\let\svendfigure\endfigure
\renewenvironment{figure}[1][htbp]{\svfigure[#1]\renewcommand\arraystretch{1.3}}
{\svendfigure}

\begin{document}
\setstretch{1.3}

\lipsum[1]

\bigskip
\begin{tabular}{ r | r | r }
         7168 &       1623040  &  28.30    \\
        14336 &       3228672  &  28.15    \\
        28160 &       6439936  &  28.59    \\
        56320 &      12862464  &  28.55    \\
       110592 &      25707520  &  29.06    \\
\end{tabular}

\begin{figure}[ht]
\begin{tabular}{ r | r | r }
         7168 &       1623040  &  28.30    \\
        14336 &       3228672  &  28.15    \\
        28160 &       6439936  &  28.59    \\
        56320 &      12862464  &  28.55    \\
       110592 &      25707520  &  29.06    \\
\end{tabular}
\end{figure}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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