我习惯于使用tabularx
宽度均匀分布的列。
\usepackage{tabularx}
\newcolumntype{Y}{>{\centering\arraybackslash}X} %centered and extended width column type
我有一列始终包含四位数字,因此该列的内容在每一行中始终具有相同的对齐方式
\begin{document}
\begin{center}
\begin{tabularx}{0.75\textwidth}{*{7}{|Y}|}
\hline
N° & A & B & C & D & E & F \\ \hline
5463 & some & useful & content & goes & right & here \\ \hline
4353 & some & other & content & goes & here & too\\ \hline
\end{tabularx}
\end{center}
\end{document}
遗憾的是,我时不时就需要一个脚注,这会搞乱对齐并使其看起来很糟糕。
\begin{document}
\begin{center}
\begin{tabularx}{0.75\textwidth}{*{7}{|Y}|}
\hline
N° & A & B & C & D & E & F \\ \hline
5463 & some & useful & content & goes & right & here \\ \hline
4353\footnote{A footnote is needed here} & some & other & content & goes & here & too\\ \hline
\end{tabularx}
\end{center}
\end{document}
有没有办法让四位数字居中,并让脚注索引出现在右侧?
答案1
您必须隐藏脚注的宽度,这可以通过在零宽度框中设置脚注标记来实现。
\documentclass{article}
\usepackage{tabularx}
\newcolumntype{Y}{>{\centering\arraybackslash}X} %centered and extended width column type
\newcommand{\hfootnote}[1]{%
\makebox[0pt][l]{\footnotemark}%
\footnotetext{#1}%
}
\setlength{\textheight}{2.5cm} % just to make a smaller picture
\begin{document}
\begin{center}
\begin{tabularx}{\textwidth}{*{7}{|Y}|}
\hline
N° & A & B & C & D & E & F \\ \hline
5463 & some & useful & content & goes & right & here \\ \hline
4353\hfootnote{abc} & some & other & content & goes & here & too\\ \hline
\end{tabularx}
\end{center}
\end{document}
答案2
尝试这个:
\documentclass{article}
\usepackage{geometry}
\geometry{
paperwidth=18cm,
paperheight=4cm,
margin=0.5cm
}
\usepackage{tabularx}
\usepackage{array}
\usepackage{booktabs}
\usepackage{siunitx}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
%S[table-format=2.0]
%>{\centering\arraybackslash}X
\begin{document}
\begin{tabularx}{0.75\textwidth}{|S[table-format=4.0, table-column-width=.95cm] *{6}{|Y}|}
\hline
\multicolumn{1}{|Y|}{N°} & A & B & C & D & E & F \\ \hline
5463 & some & useful & content & goes & right & here \\ \hline
4353\footnote{A footnote is needed here} & some & other & content & goes & here & too\\ \hline
\end{tabularx}
\end{document}