# Centering a table inside text block

I have a table in my document, but for some reason it is not in the middle of the page, as I can see more whitespace at the right side.

Here is the source code for the table:

\begin{table}[H]
\centering
$\begin{array}{ cccc } \toprule \text{harmonisch} & \text{Periode} & \text{frequency} & \text{frequency} \\ & & (\text{Zyklus/Probenahmeintervall}) & (\text{Radiant/Probenahmeintervall}) \\ \midrule 1 & n & 1/n & 2\pi/n \\ 2 & n/2 & 2/n & 4\pi/n \\ 3 & n/3 & 3/n & 6\pi/n \\ \vdots & \vdots & \vdots & \\ n/2-1 & n/(n/2-1)/n & (n/2-1)/n & (n-2)\pi/n \\ n/2 & 2 & 1/n & \pi \\ \bottomrule \end{array}$
\end{table}


Your table is too wide, hence centering in unvisible. Please try to divide Zyklus/Probenahmeintervall and Radiant/Probenahmeintervall into two or even three verses (I dont't know rules of hyphenation in German, hence no practical example) and the result should be visible. Of course, in that case, it is probably better to move harmonisch and Periode one line down.

In an example for the first case \texwidth is enlarged to see the centering.

\documentclass{article}

\usepackage{booktabs}
\usepackage{amsmath}

\textwidth15cm
\begin{document}

I have a table in my text, some how it is not in the middle of the page. I see more white space at the right side.
I have a table in my text, some how it is not in the middle of the page. I see more white space at the right side.
I have a table in my text, some how it is not in the middle of the page. I see more white space at the right side.
I have a table in my text, some how it is not in the middle of the page. I see more white space at the right side.

\begin{table}
\centering
$\begin{array}{ cccc } \toprule & & \text{frequency} & \text{frequency} \\ \text{harmonisch} &\text{Periode} & (\text{Zyklus/} & (\text{Radiant/}) \\ &&\text{Probenahmeintervall}) & \text{Probenahmeintervall}) \\ \midrule 1 & n & 1/n & 2\pi/n \\ 2 & n/2 & 2/n & 4\pi/n \\ 3 & n/3 & 3/n & 6\pi/n \\ \vdots & \vdots & \vdots & \\ n/2-1 & n/(n/2-1)/n & (n/2-1)/n & (n-2)\pi/n \\ n/2 & 2 & 1/n & \pi \\ \bottomrule \end{array}$
\end{table}

\end{document}


In the future please provide a full Minimum Working Example of your problem, it takes some of the guesswork out of helping you.

The problem is your table is wider than the textwidth of your document. The \centering environment has pushed it all the way to the left margin, but since it can't violate that margin, it sticks out to the right.

Two solutions: decrease table width, or decrease margins.

This is where the Minimum Working Example comes into play, because I have to guess at the margins you're using.

Assuming you're using the article document class, changing the parenthetical statements in your table shrinks the width enough that it fits within the margins:

\documentclass{article}
\usepackage{lipsum}
\usepackage{booktabs}
\usepackage{amsmath}

\begin{document}
\lipsum[1]
\begin{table}
\centering
$\begin{array}{ cccc } \toprule \text{harmonisch} & \text{Periode} & \text{frequency} & \text{frequency} \\ & & \text{\tiny (Zyklus/Probenahmeintervall)} & \text{\tiny (Radiant/Probenahmeintervall)} \\ \midrule 1 & n & 1/n & 2\pi/n \\ 2 & n/2 & 2/n & 4\pi/n \\ 3 & n/3 & 3/n & 6\pi/n \\ \vdots & \vdots & \vdots & \\ n/2-1 & n/(n/2-1)/n & (n/2-1)/n & (n-2)\pi/n \\ n/2 & 2 & 1/n & \pi \\ \bottomrule \end{array}$
\end{table}
\end{document}


The other option is to decrease your margins.

adding \usepackage[margin=1in]{geometry} to your preamble would shrink your margins to 1in on all sides, which would make the text wide enough for your original table to fit unmodified.

The table doesn't fit into the text block because of the material in the second header row and, in particular, the word "Probenahmeintervall" that occurs twice. Rather than reduce the font size to shrink the size of the stuff in the second header row, I suggest you create an acronym, say "PNI", for the long word and define the acronym's meaning in the table's legend, i.e., at the bottom of the table.

\documentclass{article}
\usepackage{booktabs,amsmath}
\usepackage{lipsum} %% filler text
\begin{document}
\begin{table}[t!]
\centering
$\begin{array}{ cccc } \toprule \text{harmonisch} & \text{Periode} & \text{frequency} & \text{frequency} \\ & & (\text{Zyklus/PNI}) & (\text{Radiant/PNI}) \\ \midrule 1 & n & 1/n & 2\pi/n \\ 2 & n/2 & 2/n & 4\pi/n \\ 3 & n/3 & 3/n & 6\pi/n \\ \vdots & \vdots & \vdots & \\ n/2-1 & n/(n/2-1)/n & (n/2-1)/n & (n-2)\pi/n \\ n/2 & 2 & 1/n & \pi \\ \bottomrule \addlinespace % insert a bit of vertical space between rule and next line \multicolumn{4}{l}{\text{PNI: Probenahmeintervall}}\\ \end{array}$
\end{table}
\lipsum[1]
\end{document}