这个表格可以放在文本的宽度上吗?我尝试了很多方法,但都没有用。
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\begin{longtable}[c]{@{\extracolsep{\fill}}cccccccccc@{}}
\centering
\caption{Zoznam, zapojenie a parametre vedení 110 kV} \label{tab:long1} \\
% First head
\hline
\multicolumn{10}{c}{Vedenia} \\
\hline
\multicolumn{1}{c}{Názov} &
\multicolumn{1}{c}{Uzol 1} &
\multicolumn{1}{c}{Uzol 2} &
\multicolumn{1}{c}{$R_1 {[}\Omega{]}$}&
\multicolumn{1}{c}{$X_1 {[}\Omega{]}$}&
\multicolumn{1}{c}{$B_1 {[}\mu S{]}$}&
\multicolumn{1}{c}{$R_0 {[}\Omega{]}$}&
\multicolumn{1}{c}{$X_0 {[}\Omega{]}$}&
\multicolumn{1}{c}{$B0 {[}\mu S{]}$}&
\multicolumn{1}{c}{$I_{dov} {[}A{]}$}
\\ \hline
\endfirsthead
% Standard head
\multicolumn{10}{c}
{{\tablename\ \thetable{} \textit{(Pokračovanie)}}} \\
\hline
\multicolumn{1}{c}{Názov} &
\multicolumn{1}{c}{Uzol 1} &
\multicolumn{1}{c}{Uzol 2} &
\multicolumn{1}{c}{$R_1 {[}\Omega{]}$}&
\multicolumn{1}{c}{$X_1 {[}\Omega{]}$}&
\multicolumn{1}{c}{$B_1 {[}\mu S{]}$}&
\multicolumn{1}{c}{$R_0 {[}\Omega{]}$}&
\multicolumn{1}{c}{$X_0 {[}\Omega{]}$}&
\multicolumn{1}{c}{$B_0 \mu S{]}$}&
\multicolumn{1}{c}{$I_{dov} {[}A{]}$}
\\ \hline
\endhead
% Footnote
\hline\multicolumn{10}{r}{{\textit{Pokračovanie na ďalšej strane...}}} \\
\endfoot
% Last footnote
\hline
\endlastfoot
%%%Table%%%
\end{longtable}
答案1
假设您使用的是标准文档类(文章、报告或书籍)之一或基于标准文档类构建的文档类,则以下代码应该可以正常工作。相对于您发布的代码片段,主要变化是将单元移动到单独的标题行;这使得每列的宽度大大减小。
以下代码还包含对 slovak/babel 与该包的一些宏之间不兼容的修复booktabs
。
\documentclass{article}
\usepackage{siunitx}
\usepackage[slovak]{babel}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{longtable}
\usepackage{booktabs}
% fix incompatibility between babel/slovak and booktabs macros:
\begingroup % see https://tex.stackexchange.com/a/112001/5001
\makeatletter
\catcode`\-=\active
\AtBeginDocument{
\def\@@@cmidrule[#1-#2]#3#4{\global\@cmidla#1\relax
\global\advance\@cmidla\m@ne
\ifnum\@cmidla>0\global\let\@gtempa\@cmidrulea\else
\global\let\@gtempa\@cmidruleb\fi
\global\@cmidlb#2\relax
\global\advance\@cmidlb-\@cmidla
\global\@thisrulewidth=#3
\@setrulekerning{#4}
\ifnum\@lastruleclass=\z@\vskip \aboverulesep\fi
\ifnum0=`{\fi}\@gtempa
\noalign{\ifnum0=`}\fi\futurenonspacelet\@tempa\@xcmidrule}
}
\endgroup
\begin{document}
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\begin{longtable}[c]{@{\extracolsep{\fill}} l *{9}{c} @{}}
%%\centering % <-- not needed
% First head
\caption{Zoznam, zapojenie a parametre vedení \qty{110}{\kilo\volt}} \label{tab:long1} \\
\toprule
Názov & \multicolumn{9}{c@{}}{Vedenia} \\
\cmidrule{2-10}
& Uzol 1 & Uzol 2 & $R_1$ & $X_1$ & $B_1$ & $R_0$ & $X_0$ & $B_0$ & $I_{\mathrm{dov}}$\\
& & & [\unit{\ohm}] & [\unit{\ohm}] & [\unit{\micro\second}]
& [\unit{\ohm}] & [\unit{\ohm}] & [\unit{\micro\second}]
& [\unit{\ampere}]\\
\midrule
\endfirsthead
%% Standard head
\multicolumn{10}{@{}l}{\tablename\ \thetable\ \textit{(Pokračovanie)}} \\
\toprule
Názov & \multicolumn{9}{c@{}}{Vedenia} \\
\cmidrule{2-10}
& Uzol 1 & Uzol 2 & $R_1$ & $X_1$ & $B_1$ & $R_0$ & $X_0$ & $B_0$ & $I_{\mathrm{dov}}$\\
& & & [\unit{\ohm}] & [\unit{\ohm}] & [\unit{\micro\second}]
& [\unit{\ohm}] & [\unit{\ohm}] & [\unit{\micro\second}]
& [\unit{\ampere}]\\
\midrule
\endhead
% Footer
\midrule
\multicolumn{10}{r@{}}{\footnotesize\emph{Pokračovanie na ďalšej strane\dots}} \\
\endfoot
% Last footer
\bottomrule
\endlastfoot
%%%Table%%%
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\end{longtable}
\end{document}
答案2
使用该tabularray
包后,表格代码简单而简短:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\DefTblrTemplate{conthead-text}{normal}{(Pokračovanie)}
\SetTblrTemplate{conthead-text}{normal}
\DefTblrTemplate{contfoot-text}{normal}{Pokračovanie na ďalšej strane \dots}
\SetTblrStyle{contfoot-text}{font=\small\sffamily\itshape, gray5}
\SetTblrTemplate{contfoot-text}{normal}
\begin{document}
\begin{longtblr}[
caption = {Zoznam, zapojenie a parametre vedení \qty{110}{\kilo\volt}},
label = {tab:long1}
]{%colsep = 3pt,
colspec = {@{} l *{9}{X[c]} @{}},
row{1} = {mode=text},
rowhead = 1
}
\toprule
\SetCell[r=2]{c} Názov
& \SetCell[c=9]{c} Vedenia
& & & & & & & & \\
\midrule
& Uzol 1 & Uzol 2
& $R_1$ [\unit{\ohm}]
& $X_1$ [\unit{\ohm}]
& $B_1$ [\unit{\micro\second}]
& $R_0$ [\unit{\ohm}]
& $X_0$ [\unit{\ohm}]
& $B_0$ [\unit{\micro\second}]
& $I_{\mathrm{dov}}$ [\unit{\ampere}]
\\
\midrule
% table body
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\
\bottomrule
\end{longtblr}
\end{document}