\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{setspace}
\usepackage{rotating}
\usepackage{array}
\usepackage{float}
\usepackage{booktabs,tabularx,dcolumn,adjustbox}
\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
Australian Capital Territory & Legalization &license& license®istration&illegal\\[0.3cm] \hline
New South Wales& Decriminalization & legal & legal& legal& legal$^1$\\[0.3cm]\hline
Northern Territories &Legalization & illegal& license& registration&illegal\\[0.3cm]\hline
Queensland &Legalization & license& illegal&legal&illegal\\[0.3cm]\hline
South Australia& Criminalization & illegal&illegal&legal&illegal\\[0.3cm]\hline
Tasmania& Criminalization & illegal&illegal&legal&illegal\\[0.3cm]\hline
Victoria & Legalization &license& license®istration&illegal\\[0.3cm]\hline
Western Australia& Criminalization &illegal& legal¬ specified$^2$&illegal\\[0.3cm]\hline
\end{tabular}
\end{minipage}
\end{sidewaystable}
我正在尝试为论文制作文本表格,但是在单元格内的文本对齐方面遇到了问题。
我想要的是让文本精确地位于每个单元格的中心。我尝试使用 token c
,m
但没有得到理想的结果,因为文本要么居中,要么在单元格的上方,要么在左上角。
我不明白的是,它适用于列标题,但不适用于单元格的内容,正如您从这张部分屏幕截图中看到的那样
我浏览了其他问题,但找到的所有答案都不符合我的确切需求。有人能提供一些提示吗?
答案1
我建议您做几项调整:
tabular
用替换tabularx
,并对五个数据列采用居中版本的X
列类型。这样做可以省去确定五个数据列应该有多宽的繁琐工作。使用较少但间距适当的水平线,不要使用任何垂直线。这样,您就不必花时间弄清楚如何将单元格内容居中。
加载
threeparttable
包并使用其机制排版与表格相关的脚注标记和脚注。
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb,setspace}
\usepackage{rotating,array,float}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\usepackage{booktabs,tabularx,dcolumn,adjustbox}
\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
Australian Capital Territory & Legalization &license& license®istration&illegal\\ \addlinespace
New South Wales& Decriminalization & legal & legal& legal& legal\tnote{1}\\ \addlinespace
Northern Territories &Legalization & illegal& license& registration&illegal\\ \addlinespace
Queensland &Legalization & license& illegal&legal&illegal\\ \addlinespace
South Australia& Criminalization & illegal&illegal&legal&illegal\\ \addlinespace
Tasmania& Criminalization & illegal&illegal&legal&illegal\\ \addlinespace
Victoria & Legalization &license& license®istration&illegal\\ \addlinespace
Western Australia& Criminalization &illegal& legal¬ 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}