如何将表格后的文本与表格起始的列对齐?

如何将表格后的文本与表格起始的列对齐?

在表格的标题之后,我有几行文字,我希望它们与表格的起始位置对齐。

表格是居中对齐的,我怎样才能找到表格的起始列以便将文本行放在那里?

\documentclass[10pt]{article}
\usepackage{textcomp}
\usepackage[utf8]{inputenc}
\usepackage{fontspec}
\usepackage[british]{babel}
\setlength{\columnsep}{25 pt} % Distance between two columns
\usepackage{graphicx}
\usepackage[left=1.5cm,right=1.5cm,top=2.5cm,bottom=3cm]{geometry} % page layout
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{xcolor}
\usepackage{calc}
\usepackage{float}
\usepackage{gensymb}
\usepackage{tabularx,ragged2e,booktabs,caption}
\usepackage{subfigure}
\usepackage{multicol,tabularx,capt-of}
\usepackage{multirow}

\begin{document}


\begin{center}
\begin{tabular}{|l|l|l|l|}
\hline
\textbf{Pin no} & \textbf{Pin name} & \textbf{Pin type} & \textbf{Function} \\
\hline
A1 & TST1 & AO & Test pin \\
\hline
A2 & VDDF & P & Analog reference voltage, internally generated \\
\hline
A3 & \# INT & DO & Interrupt, active low\\
\hline
A4 & CLK & DI & FPGA clock \\
\hline
A5 & SDO & DO & Serial data out\\
\hline
B1 & VDDA & P & Analog supply voltage\\
\hline
B2 & TST2 & AO & Test pin \\
\hline
B3 & AGND & P & Analog ground \\
\hline
B4 & \# RESET & DI & FPGA reset, active low \\
\hline
B5 & VDD1 & P & Digital core voltage, internally generated \\
\hline
Y1 & VREF & P & Analog reference voltage, internally generated\\
\hline
Y2 & AGND & P & Analog ground \\
\hline
Y3 & DGND & P & Digital ground \\
\hline
Y4 & \# CS & DI & SPI chip select, active low \\
\hline
\end{tabular}
\captionof{table}{Pin name and description}
\end{center}

AI Analog input \\
AO Analog output \\
DI Digital input \\
DO Digital output \\
P Power \\
Note: Pin names beginning with a \# character denotes that the single is active low.

\end{document}

答案1

我可以推荐这个软件包threeparttable吗?我认为这应该正是您想要实现的。这样,表格注释就会粘在表格上,并且语义上编码良好。如果您将标题放在顶部(就像我总是对表格所做的那样),它会看起来更好。

% arara: pdflatex

\documentclass[10pt]{article}
\usepackage[british]{babel}
\usepackage[left=1.5cm,right=1.5cm,top=2.5cm,bottom=3cm]{geometry}
\usepackage{booktabs,caption}
\usepackage{threeparttable}

\begin{document}
\begin{table}%[] place some limitations here, if you want to stop the floating.
\centering
\begin{threeparttable}
\begin{tabular}{llll}
\toprule
\textbf{Pin no} & \textbf{Pin name} & \textbf{Pin type} & \textbf{Function} \\
\midrule
A1 & TST1 & AO & Test pin \\
A2 & VDDF & P & Analog reference voltage, internally generated \\
A3 & \# INT & DO & Interrupt, active low\\
A4 & CLK & DI & FPGA clock \\
A5 & SDO & DO & Serial data out\\
B1 & VDDA & P & Analog supply voltage\\
B2 & TST2 & AO & Test pin \\
B3 & AGND & P & Analog ground \\
B4 & \# RESET & DI & FPGA reset, active low \\
B5 & VDD1 & P & Digital core voltage, internally generated \\
Y1 & VREF & P & Analog reference voltage, internally generated\\
Y2 & AGND & P & Analog ground \\
Y3 & DGND & P & Digital ground \\
Y4 & \# CS & DI & SPI chip select, active low \\
\bottomrule
\end{tabular}
\caption{Pin name and description} % set this in front of \toprule in order to get the notes closer to the table
\begin{tablenotes}[flushleft] % you may leave the default (no options) if you like. Like this it is left aligned as you asked for.
\item AI Analog input
\item AO Analog output
\item DI Digital input
\item DO Digital output
\item P Power
\item Note: Pin names beginning with a \# character denotes that the single is active low.
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}

在此处输入图片描述

您也可以将此解决方案用于您的表格。我只是改用了,booktabs因为我认为它更易于阅读并且具有更好的垂直间距。您可以轻松地将原始 MWE 包装在这样的 中threeparttable

相关内容