# Centering continues to next page after sideways table

I have used this guide to create a sideways table.

However, for some reason the \centering continues to the next page.

\begin{appendices}
\section{This Section} \label{thissection}
\vfil
\sbox0{\begin{tabular}{|l|c|c|c|c|c|c|c|c|c|c|c|c|}
\hline
...stuff here...
\end{tabular}}
\centering
\rotatebox[origin=c]{90}{\begin{minipage}{\wd0}
\usebox0
\captionof{table}{Relation between frequencies and pitches.}
\end{minipage}}

\clearpage
\section{That Section}
Unfortunately, this section is centered!!!


What could be the issue here?

Here is an editable version of this.

I tried \begingroup ... \endgroup but it removes the centering from the table as well.

• The examples on the linked page use the center environment or \centering within a floating enviroment. In either case, the centering is limited to a certain scope. This is not the case in your example. Try wrapping the whole tabular handling into \begingroup ... \endgroup, or paste a compilable example document to work with. – siracusa Jun 19 '17 at 4:09
• Thanks for commenting. I added an editable version of this. – pavlos163 Jun 19 '17 at 4:21
• Please, extend your code sniped to complete (but small) document with \documentclass{...} on beginning and \end{document} on the end. – Zarko Jun 19 '17 at 5:10
• Hi Zarko. I have added a link to an editable version of the document. – pavlos163 Jun 19 '17 at 5:12
• but there you also have a solutions ... and use siracusa comment: \sbox0{\begin{tabular}{|l|c|c|c|c|c|c|c|c|c|c|c|c|} \hline ...stuff here... \hline\end{tabular}} \begingroup\centering \rotatebox[origin=c]{90}{\begin{minipage}{\wd0}\usebox0 \endgroup \captionof{table}{Relation between frequencies and pitches.} \end{minipage}} – Zarko Jun 19 '17 at 5:25

You can find guides to making a minimal example, here and here. If you follow those, and remove everything from your document which doesn't affect the problem (including the \clearpage), you'll be left with something like this:

\documentclass{article}
\usepackage{caption}
\usepackage{rotating}

\begin{document}
\section{The Table}
\sbox0{%
\begin{tabular}{|c|c|c|c|}
\hline
\textbf{G$\sharp$} & \textbf{A} & \textbf{B$\flat$} & \textbf{B} \\ \hline
\end{tabular}%
}

\centering
\rotatebox[origin=c]{90}{%
\begin{minipage}{\wd0}
\usebox0
\captionof{table}{A table.}
\end{minipage}%
}

\section{That Section}
Something something something.

\end{document}


producing

(actually the example could be minimized even more) from which the error is obvious: the \centering occurs at the top level, so its effect will last forever, regardless of \clearpage or whatever.

So you need to put the \centering into a group. You can do this with { and } (or \begingroup and \endgroup, or \bgroup and \egroup):

\documentclass{article}
\usepackage{caption}
\usepackage{rotating}

\begin{document}
\section{The Table}
\sbox0{%
\begin{tabular}{|c|c|c|c|}
\hline
\textbf{G$\sharp$} & \textbf{A} & \textbf{B$\flat$} & \textbf{B} \\ \hline
\end{tabular}%
}

{\centering
\rotatebox[origin=c]{90}{%
\begin{minipage}{\wd0}
\usebox0
\captionof{table}{A table.}
\end{minipage}%
}

} % The above blank line is necessary

\section{That Section}
Something something something.

\end{document}


The above produces:

as you probably wanted.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[titletoc,page]{appendix}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[titletoc,page]{appendix}
\usepackage{fancyhdr}
\usepackage{parskip}
\usepackage{geometry}
\usepackage{rotating}
\usepackage{amssymb}

\begin{document}
\begin{appendices}
\section{The Table}
\vfil
\sbox0{\begin{tabular}{|l|c|c|c|c|c|c|c|c|c|c|c|c|}
\hline
& \textbf{C} & \textbf{C$\sharp$} & \textbf{D} & \textbf{E$\flat$} & \textbf{E} & \textbf{F} & \textbf{F$\sharp$} & \textbf{G} & \textbf{G$\sharp$} & \textbf{A} & \textbf{B$\flat$} & \textbf{B} \\ \hline
\textbf{0} & 16.35      & 17.32              & 18.35      & 19.45             & 20.6       & 21.83      & 23.12              & 24.5       & 25.96              & 27.5       & 29.14             & 30.87      \\ \hline
\textbf{1} & 32.7       & 34.65              & 36.71      & 38.89             & 41.2       & 43.65      & 46.25              & 49         & 51.91              & 55         & 58.27             & 61.74      \\ \hline
\textbf{2} & 65.41      & 69.3               & 73.42      & 77.78             & 82.41      & 87.31      & 92.5               & 98         & 103.8              & 110        & 116.5             & 123.5      \\ \hline
\textbf{3} & 130.8      & 138.6              & 146.8      & 155.6             & 164.8      & 174.6      & 185                & 196        & 207.7              & 220        & 233.1             & 246.9      \\ \hline
\textbf{4} & 261.6      & 277.2              & 293.7      & 311.1             & 329.6      & 349.2      & 370                & 392        & 415.3              & 440        & 466.2             & 493.9      \\ \hline
\textbf{5} & 523.3      & 554.4              & 587.3      & 622.3             & 659.3      & 698.5      & 740                & 784        & 830.6              & 880        & 932.3             & 987.8      \\ \hline
\textbf{6} & 1047       & 1109               & 1175       & 1245              & 1319       & 1397       & 1480               & 1568       & 1661               & 1760       & 1865              & 1976       \\ \hline
\textbf{7} & 2093       & 2217               & 2349       & 2489              & 2637       & 2794       & 2960               & 3136       & 3322               & 3520       & 3729              & 3951       \\ \hline
\textbf{8} & 4186       & 4435               & 4699       & 4978              & 5274       & 5588       & 5920               & 6272       & 6645               & 7040       & 7459              & 7902       \\ \hline
\end{tabular}}
{\centering
\rotatebox[origin=c]{90}{\begin{minipage}{\wd0}
\usebox0
\captionof{table}{A table.}
\end{minipage}}

} % The blank line above is necessary

\clearpage
\section{That Section}
Something something something.
\end{appendices}

\end{document}

• \flushleft is a bad idea, as it removes justification. Add a \lipsum[1] before and after to see that. The center environment is another option. – Torbjørn T. Jun 19 '17 at 10:44
• @TorbjørnT. Thanks you're right, removed it. – ShreevatsaR Jun 19 '17 at 15:05