我尝试了这个,但是没有用
\begin{table}
\caption{A table with rounded corners}
\centering
\begin{tikzpicture}
\node (table) [inner sep=0pt] {
\begin{longtable}{l|l}
\multicolumn{2}{c}{Team sheet} \\
\hline
GK & Paul Robinson \\
LB & Lucus Radebe \\
DC & Michael Duberry \\
DC & Dominic Matteo \\
RB & Didier Domi \\
MC & David Batty \\
MC & Eirik Bakke \\
MC & Jody Morris \\
FW & Jamie McMaster \\
ST & Alan Smith \\
ST & Mark Viduka \\
\end{longtable}
};
\draw [rounded corners=.5em] (table.north west) rectangle (table.south east);
\end{tikzpicture}
\label{tab1}
\end{table}
答案1
这是你想获得的吗:
\documentclass[11pt, border=1mm,
preview]{standalone}
\usepackage[many]{tcolorbox}
\begin{document}
\begin{table}
\caption{A table with rounded corners}
\centering
\tcbox[left=0mm,right=0mm,top=0mm,bottom=0mm,boxsep=0mm,
boxrule=0.4pt, colback=white]% set to your wish
{\begin{tabular}{l|l}
\multicolumn{2}{c}{Team sheet} \\
\hline% if you liked
GK & Paul Robinson \\
LB & Lucus Radebe \\
DC & Michael Duberry \\
DC & Dominic Matteo \\
RB & Didier Domi \\
MC & David Batty \\
MC & Eirik Bakke \\
MC & Jody Morris \\
FW & Jamie McMaster \\
ST & Alan Smith \\
ST & Mark Viduka
\end{tabular}}
\label{tab1}
\end{table}
\end{document}
编辑/升级:
对于 longtable 的使用...您需要tcolorbox
宽度选项breakable
和一些手动调整来调整框宽度或使用其他表格环境,类似于xtab
,它模拟tabularx
对给定框宽度的适应。
\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{longtable}
\usepackage{lipsum}
\begin{document}
\lipsum[1-4]
\centering
\tcbset{enhanced jigsaw,% if you like to have rounded corners
% on each end/beginning of table,
% than remove this option
breakable,
left=0mm,right=0mm,top=0mm,bottom=0mm,boxsep=0mm,
boxrule=0.4pt, colback=white}% set to your wish
\begin{tcolorbox}[width=4.05cm]% width determined "experimentally"
\begin{longtable}{l|l}
\multicolumn{2}{c}{Team sheet} \\
\hline% if you liked
GK & Paul Robinson \\
LB & Lucus Radebe \\
DC & Michael Duberry \\
DC & Dominic Matteo \\
RB & Didier Domi \\
MC & David Batty \\
MC & Eirik Bakke \\
MC & Jody Morris \\
FW & Jamie McMaster \\
ST & Alan Smith \\
ST & Mark Viduka
\end{longtable}
\end{tcolorbox}
\end{document}
此代码提供:
我没有考虑标题问题。可以在longtable
或 内完成tcolorbox
。有关后者,请参阅 tcolorbox 手册,第 304 页的 Library "breakable! 一章。上述解决方案的不足之处在于手动调整 tcolorbox 宽度,但是,正如我已经提到的,使用其他表格环境,可以轻松解决这个问题