社区中还有一些与此问题相关的其他问题,但我很难将其适应我的具体情况。我有以下代码:
\begin{table}[hbtp!]
\centering
\begin{tabular}{ll}
\multicolumn{2}{c}{\textbf{Relevant indicators (Cluster 1)}} \\ \hline
\multicolumn{1}{l|}{GDP growth (annual \%)} & Reserves and related items (\% GDP) \\
\multicolumn{1}{l|}{\textbf{Claims on central government (\% GDP)}} & Current account balance (\% GDP) \\
\multicolumn{1}{l|}{\textbf{Commercial service exports (\% GDP)}} & \textbf{Gross capital formation (\% GDP)} \\
\multicolumn{1}{l|}{\textbf{Commercial service imports (\% GDP)}} & \textbf{Gross domestic savings (\% GDP)} \\
\multicolumn{1}{l|}{Consumer price index (\% change)} & Total reserves (includes gold, \% GDP) \\
\multicolumn{1}{l|}{Imports of goods and services (\% GDP)} & \textbf{FDI, net inflows (\% GDP)}
\end{tabular}
\label{tableCL1}
\bigskip
\centering
\begin{tabular}{ll}
\multicolumn{2}{c}{\textbf{Relevant indicators (Cluster 2)}} \\ \hline
\multicolumn{1}{l|}{\textbf{GDP growth (annual \%)}} & Current account balance (\% GDP) \\
\multicolumn{1}{l|}{Claims on central government (\% GDP)} & Gross capital formation (\% GDP) \\
\multicolumn{1}{l|}{Consumer price index (\% change)} & \textbf{Total reserves (includes gold, \% GDP)} \\
\multicolumn{1}{l|}{Reserves and related items (\% GDP)} & \textbf{Exports of goods and services (\% GDP)}
\end{tabular}
\label{tableCL2}
\bigskip
\centering
\begin{tabular}{ll}
\multicolumn{2}{c}{\textbf{Relevant indicators (Cluster 3)}} \\ \hline
\multicolumn{1}{l|}{GDP growth (annual \%)} & Current account balance (\% GDP) \\
\multicolumn{1}{l|}{\textbf{Claims on central government (\% GDP)}} & Gross capital formation (\% GDP) \\
\multicolumn{1}{l|}{Commercial service exports (\% GDP)} & Gross domestic savings (\% GDP) \\
\multicolumn{1}{l|}{\textbf{Consumer price index (\% change)}} & Exports of goods and services (\% GDP) \\
\multicolumn{1}{l|}{Reserves and related items (\% GDP)} & Total reserves (includes gold, \% GDP) \\
\multicolumn{1}{l|}{Imports of goods and services (\% GDP)} &
\end{tabular}
\caption{The macroeconomic indicators recovered by the panel analogue of the elastic net. The indicators in bold are significant at the 5\% level.}
\label{tableCL3}
\end{table}
其结果如下:
但是,如您所见,中心线(用红色标记)未对齐。如何实现?提前致谢。
答案1
我认为您需要重点确保表格不超过文本块的宽度。目前,您的代码中没有任何内容可以保证此排版标准。我建议您加载包tabularx
并使用其同名环境来实现排版目标。这种方法还可以让您准备好大量视觉格式代码混乱。此外,我建议您将所有三个类似表格的结构封装在subtable
环境中,并为每个结构提供自己的subtable
指令\caption
。这样,您可以告诉 LaTeX 创建对各个子表的交叉引用,而不仅仅是整个表。
\documentclass{article} % or some other suitable document class
\usepackage{tabularx,ragged2e}
\newcolumntype{L}{>{\RaggedRight}X}
\usepackage{subcaption}
\captionsetup[subtable]{font=bf,skip=0.333\baselineskip}
\begin{document}
\section{Introduction}
\begin{table}[hbtp!]
\setlength\extrarowheight{1pt}
\begin{subtable}{\textwidth}
\caption{Relevant indicators, Cluster 1}
\label{tableCL1}
\begin{tabularx}{\textwidth}{@{} L|L @{}}
\hline
GDP growth (\% p.a.)
& Reserves and related items \\
\textbf{Claims on central government }
& Current account balance \\
\textbf{Commercial service exports }
& \textbf{Gross capital formation } \\
\textbf{Commercial service imports }
& \textbf{Gross domestic savings } \\
Cons.\ price index growth (\% p.a.)
& Total reserves (incl.\ gold) \\
Imports of goods and services
& \textbf{FDI, net inflows }
\end{tabularx}
\end{subtable}
\bigskip
\begin{subtable}{\textwidth}
\caption{Relevant indicators, Cluster 2}
\label{tableCL2}
\begin{tabularx}{\textwidth}{@{} L|L @{}}
\hline
\textbf{GDP growth} (\% p.a.)
& Current account balance \\
Claims on central government
& Gross capital formation \\
Cons.\ price index growth (\% p.a.)
& \textbf{Total reserves (incl.\ gold)} \\
Reserves and related items
& \textbf{Exports of goods and services }
\end{tabularx}
\end{subtable}
\bigskip
\begin{subtable}{\textwidth}
\caption{Relevant indicators, Cluster 3}
\label{tableCL3}
\begin{tabularx}{\textwidth}{@{} L|L @{}}
\hline
GDP growth (\% p.a.)
& Current account balance \\
\textbf{Claims on central government }
& Gross capital formation \\
Commercial service exports
& Gross domestic savings \\
\textbf{Cons.\ price index growth} (\% p.a.)
& Exports of goods and services \\
Reserves and related items
& Total reserves (incl.\ gold) \\
Imports of goods and services &
\end{tabularx}
\end{subtable}
\caption{The macroeconomic indicators recovered by the panel analogue of the elastic net. The indicators in bold are statistically significant at the 5\% level. All indicators are measured in \% of GDP unless indicated otherwise.}
\label{tableCL}
\end{table}
\end{document}