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}
cxxl
  • 1,183

2 Answers2

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

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}