# Align text in the middle of a table cell [duplicate]

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{setspace}
\usepackage{rotating}
\usepackage{array}
\usepackage{float}
\usepackage[font=normal,skip=.333\baselineskip]{caption}
\usepackage[margin=2.5cm]{geometry}
\usepackage[strict]{changepage}
\usepackage{longtable}

\begin{sidewaystable}
\begin{minipage}[H]{\linewidth}
\centering
\begin{tabular}{ |l|m{3.5cm}|m{3.5cm}|m{3.5cm}|m{3.5cm}|m{3.5cm}|}
\hline
\textbf{State/Territory}& \textbf{Type of legislation} &\textbf{Brothels}&\textbf{Escort agencies}&\textbf{Private work}&\textbf{Street work}\\[0.3cm]
\hline\hline
New South Wales&   Decriminalization  & legal   & legal& legal& legal$^1$\\[0.3cm]\hline
Northern Territories &Legalization & illegal&  license&  registration&illegal\\[0.3cm]\hline
South Australia&   Criminalization  & illegal&illegal&legal&illegal\\[0.3cm]\hline
Tasmania&   Criminalization  & illegal&illegal&legal&illegal\\[0.3cm]\hline
Western Australia& Criminalization  &illegal&   legal&not specified$^2$&illegal\\[0.3cm]\hline
\end{tabular}
\end{minipage}
\end{sidewaystable}


I am trying to produce a table of text for a paper but I am having issues with the alignment of text inside the cells.

What I am trying to obtain is to have the text exactly in the center of each cell. I tried with tokens c and m but I am not obtaining my ideal result because the text is either centered but up in the cell or on the upper left.

What I am not getting is that it works for column titles but not for the content of the cells as you can see from this partial screenshot

I went around the other questions but all the answers I found do not match my exact need. Does anybody have any hint?

• I think this is what you want. Jun 4 '19 at 14:35

I suggest you make several adjustments:

• Replace tabular with tabularx, and employ a centered version of the X column type for the five data columns. Doing so eliminates the tedious work of determining how wide the five data columns should be.

• Use fewer, but well-spaced, horizontal lines, don't use any vertical lines. That way, you don't have to spend any time at all figuring out how to center the cell contents.

• Load the threeparttable package and use its machinery to typeset the table-related footnote markers and footnotes.

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb,setspace}
\usepackage{rotating,array,float}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\usepackage[font=normal,skip=.333\baselineskip]{caption}
\usepackage[margin=2.5cm]{geometry}
\usepackage[strict]{changepage}
\usepackage[flushleft]{threeparttable} % new
\begin{document}

\begin{sidewaystable}
\begin{threeparttable}
\caption{\dots}

\begin{tabularx}{\textwidth}{@{} l *{5}{C} @{}}
\toprule
\textbf{State/Territory}
& \textbf{Type of legislation}
& \textbf{Brothels}
& \textbf{Escort agencies}
& \textbf{Private work}
& \textbf{Street work}\\
\midrule
New South Wales&   Decriminalization  & legal   & legal& legal& legal\tnote{1}\\ \addlinespace
South Australia&   Criminalization  & illegal&illegal&legal&illegal\\ \addlinespace
Western Australia& Criminalization  &illegal&   legal&not specified\tnote{2}&illegal\\
\bottomrule
\end{tabularx}

\medskip
\begin{tablenotes}
\footnotesize
\item[1] \dots
\item[2] \dots
\end{tablenotes}
\end{threeparttable}
\end{sidewaystable}
\end{document}