3

I've defined the following macro:

% makes tables more readable  
\renewcommand{\arraystretch}{1.1}  
\setlength{\tabcolsep}{5pt}

Which add extra tabbing space in the tables. However, in one place in my report I need to use the default as it messes up the structure of the page (I have a side-by-side table and figures). I wonder if I could, for some table environments, reset the tabbing space to default?

2 Answers 2

5

You can create a command to store the old length so you can go back to it later. For lengths, you could do like this:

\newlength{\myparindent}
\setlength{\myparindent}{\parindent}
\setlength{\parindent}{2em}

%restore original
\setlength{\parindent}{\myparindent}
4

Store the modifying macros in a macro that you can call where you need it:

enter image description here

\documentclass{article}

% Store modifiable content
\newlength{\storetabcolsep}
\AtBeginDocument{%
  \let\storearraystretch\arraystretch% \arraystretch
  \setlength{\storetabcolsep}{\tabcolsep}% \tabcolsep
}

% Makes tables more readable
\newcommand{\increasetablespace}{%
  \renewcommand{\arraystretch}{1.5}%
  \setlength{\tabcolsep}{12pt}}%
% Restore stretching defaults
\newcommand{\restoretablespace}{%
  \let\arraystretch\storearraystretch% \arraystretch
  \setlength{\tabcolsep}{\storetabcolsep}}% \tabcolsep

\begin{document}

\increasetablespace
\begin{tabular}{ccc}
  \hline
  A & B & C \\
  \hline
  1 & 2 & 3 \\
  \hline
\end{tabular}

\bigskip

\restoretablespace
\begin{tabular}{ccc}
  \hline
  A & B & C \\
  \hline
  1 & 2 & 3 \\
  \hline
\end{tabular}

\end{document}

The idea is to store any content that you potentially modify within the document \AtBeginDocument. Then, via macro calls \increasetablespace they're updated to suit your stretched-out needs, and restored using \restoretablespace.

1
  • i'd be inclined to call it \defaulttablespace (even if it's hard to spell correctly) instead of \restoretablespace, since the latter might imply i'm restoring it to some alternate that i've defined that isn't the default. Apr 1, 2015 at 21:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .