1

Can this table be put on the width of the text ? I have tried many things but they didn't work.

\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}

Bernard
  • 271,350

2 Answers2

2

Assuming you're using one of the standard document classes (article, report, or book) or a document class that's built on a standard document class, the following code should work just fine. A main change, relative to the code fragment you posted, is moving the units to a separate header row; this makes each column just that much less wide.

The following code also contains a fix for an incompatibility between slovak/babel and some of the macros of the booktabs package.

enter image description here

\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}

Mico
  • 506,678
0

With use of the tabularray package the table code is simple and short:

\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}

enter image description here

Zarko
  • 296,517