在 LaTex 中创建一个表格,并希望各列由垂直线分隔。
\begin{table}[htbp]
\centering
\caption{TestTable}
\begin{tabular}{c | c}
Sample & \multicolumn{1}{l}{Data} \\
\hline
\multicolumn{1}{r}{123123} & 12312 \\
\multicolumn{1}{r}{234234} & 324534 \\
\multicolumn{1}{r}{4534} & 324234 \\
\multicolumn{1}{r}{23423} & 345345 \\
\multicolumn{1}{r}{345345} & 32423 \\
ter23423 & 4562 \\
\end{tabular}%
\label{tab:addlabel}%
\end{table}%
答案1
将列说明符更改为您只需要针对单词 Sample 执行{r|c}
一个命令:multicolumn
\documentclass{article}
\begin{document}
\begin{table}[htbp]
\centering
\caption{TestTable}
\begin{tabular}{r|c}
\multicolumn{1}{c|}{Sample} & \multicolumn{1}{l}{Data} \\
\hline
123123 & 12312 \\
234234 & 324534 \\
4534 & 324234 \\
23423 & 345345 \\
345345 & 32423 \\
ter23423 & 4562 \\
\end{tabular}%
\label{tab:addlabel}%
\end{table}%
\end{document}