2

I was just figuring out how to cite multiple lines to same footnote. I use \usepackage{threeparttable} to do so. However, the table I am making is quite large (over 70 lines), and this seems to have messed up with the \centering command. The table has shifted to the right.

Now, I am using resizebox to fit the whole thing into one page, and I am not comfortable picking random \renewcommand because I am not always sure what that could do to my specific case.

The table is still all in within the page, but I would really love to have it centered.

Here is minimum viable code, and part of the table.

\documentclass[a4paper,12pt,twoside,BCOR=10mm]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[icelandic]{babel}
% \usepackage{t1enc}
\usepackage[T1]{fontenc}
\usepackage[dvipsnames]{xcolor}
\usepackage{graphicx,booktabs}
\usepackage[intoc]{nomencl}
\usepackage{enumerate,color}
\usepackage{url}
\usepackage{appendix}
\usepackage{float}
\usepackage{eso-pic}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{longtable}
\usepackage{acronym}
\usepackage{nicematrix}
\usepackage{makecell}
% \usepackage{tablefootnote}
\usepackage{threeparttable}
%\usepackage[sf,normalsize]{subfigure}
\usepackage[format=plain,labelformat=simple,labelsep=colon]{caption}
\usepackage{placeins}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{adjustbox}
\usepackage{subcaption}
%\usepackage{subfig}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{external}
% Packages used for title page layout
\usepackage{tikz}
\usetikzlibrary{positioning}

\usepackage[pdfborder={0 0 0}]{hyperref} % \usepackage{scrextend}

\begin{document \begin{table} \centering {\small\renewcommand{\arraystretch}{.8} \caption{Spá um raforkunotkun, forgangsorka og skerðanleg orka. Almenn notkun að meðtöldum dreifitöpum og núverandi og samþykktir nýir stórnotendur. \label{table:Orkuspá}} \resizebox{!}{.31\paperheight}{ \begin{threeparttable} \begin{NiceTabular}{lcccccccccc} \hline \Block{2-1}{Ár} & \Block{1-2}{Úttekt frá dreifikerfinu\ forgangs- og skerðanleg\ orka með dreifitöpum} & & \Block{1-2}{Úttekt frá\ flutningskerfinu} & & \Block{1-2}{Flutningstöp} & & \Block{1-2}{Úttekt frá \ vinnslufyrirtækjum} & & \Block{1-2}{Samtals} \ & Orka GWh & Afl MW & Orka GWh & Afl MW & Orka GWh & Afl MW & Orka GWh & Afl MW & Orka GWh & Afl MW \ \hline 2015 \tnote{1} & 3.604,74 & 618,46 & 14.356,34 & 1.685,89 & 369,56 & 57,11 & 468,32 & 75,40 & 18.798,96 & 2.383,25 \ 2016 \tnote{1} & 3.383,99 & 590,10 & 14.334,19 & 1.695,96 & 360,42 & 57,05 & 470,86 & 71,46 & 18.549,46 & 2.378,51 \ 2017 \tnote{1} & 3.519,13 & 608,86 & 14.869,95 & 1.750,87 & 373,07 & 61,49 & 476,38 & 84,74 & 19.238,53 & 2.443,61 \ 2018 \tnote{1} & 3.682,07 & 623,26 & 15.259,88 & 1.838,28 & 398,09 & 70,47 & 489,75 & 70,71 & 19.829,79 & 2.519,53 \ 2019 \tnote{1} & 3.506,86 & 596,63 & 15.145,31 & 1.829,48 & 365,82 & 63,40 & 476,84 & 85,11 & 19.494,83 & 2.495,07 \ 2020 \tnote{1} & 3.473,77 & 596,83 & 14.830,70 & 1.790,95 & 353,09 & 60,54 & 469,74 & 72,27 & 19.127,30 & 2.408,28 \ 2021 & 3.688,10 & 630,47 & 15.539,59 & 1.865,64 & 397,70 & 67,72 & 479,82 & 73,82 & 20.105,21 & 2.584,89 \ 2022 & 3.785,98 & 647,81 & 16.099,28 & 1.875,76 & 416,40 & 69,68 & 490,14 & 75,41 & 20.791,80 & 2.615,29 \ \hline \end{NiceTabular} \begin{tablenotes} \item[1] Rauntölur \end{tablenotes} \end{threeparttable}}} \end{table} \end{document}

I am sorry if I come off as dry, I am just tired after long day, and that same footnote over many lines took way too much time to figure out.

2 Answers2

1

The phenomenon you describe as "the table shifting to the right" is almost certainly an optical illusion, caused by the fact that the table is very wide due to its having 11 columns.

I would advise strongly against using either \resizebox or the adjustbox machinery to cram the table into a single page, as that trick will almost certainly result in the material being rendered so tiny as to make it utterly illegible and indecipherable.

Instead, I suggest you use one or more landscape-mode pages to render the table. Just how many are needed depends on how many rows the real table has.

The following screenshot shows the result of rendering the table provided in your code in a sidewaystable environment. Note that I've employed some of the machinery of the siunitx package to help auto-format the numerical data. If your table needs to be displayed across several sidewaystable environments, be sure to employ the \ContinuedFloat macro of the \caption package to help adjust the numbering of the table captions.

enter image description here

I'm afraid I don't understand Icelandic, but I can't help but remark that it might be useful if you made the sub-header above data columns 1 and 2 less, well, wordy. :-)

\documentclass[a4paper,12pt,twoside,BCOR=10mm]{scrbook}
% \usepackage[utf8]{inputenc} % that's the default nowadays
\usepackage[icelandic]{babel}
\usepackage[T1]{fontenc}
\usepackage[dvipsnames]{xcolor}
\usepackage{graphicx}
\usepackage{booktabs} % for well-spaced horizontal rules
\usepackage[intoc]{nomencl}
\usepackage{enumerate} %,color
\usepackage{xurl} % allow linebreaks at arbitrary points in a long URL string
\usepackage{appendix}
\usepackage{eso-pic}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{longtable}
\usepackage{acronym}
\usepackage{nicematrix}
\usepackage{makecell}

\usepackage[flushleft]{threeparttable} % <-- use 'flushleft' option

\usepackage[format=plain,labelformat=simple,labelsep=colon]{caption} \usepackage{subcaption}

\usepackage{placeins} \usepackage{tabularx} \usepackage{multirow} %%%%\usepackage{adjustbox}

\usepackage{pgfplots} \pgfplotsset{compat=newest} \usepgfplotslibrary{external} \usepackage{tikz} \usetikzlibrary{positioning}

\usepackage[pdfborder={0 0 0}]{hyperref}

% new code: \usepackage[figuresright]{rotating} % for 'sidewaystable' env. \usepackage{siunitx} \newcolumntype{T}[1]{S[table-format=#1]} \newcommand\mybox[1]{\multicolumn{2}{c}{% \begin{tabular}[t]{@{} c @{}} #1 \end{tabular}}}

% \usepackage{scrextend}

\begin{document}

\begin{sidewaystable} \sisetup{group-minimum-digits =4, group-separator ={.}, output-decimal-marker={,}} \setlength\tabcolsep{0pt} % let LaTeX figure out intercol. separation

\begin{threeparttable}

\caption{Spá um raforkunotkun, forgangsorka og skerðanleg orka. Almenn notkun að meðtöldum dreifitöpum og núverandi og samþykktir nýir stórnotendur.\strut} \label{table:Orkuspá}

\begin{tabular}{\textwidth}{@{\extracolsep{\fill}} l
T{4.2}T{3.2} T{5.2}T{4.2}
{2}{T{3.2}T{2.2}} T{5.2}T{4.2} } \toprule Ár & \mybox{Úttekt frá dreifikerfinu\ forgangs- og skerðanleg\ orka með dreifitöpum} & \mybox{Úttekt frá\ flutningskerfinu} & \mybox{Flutningstöp} & \mybox{Úttekt frá \ vinnslufyrirtækjum} & \mybox{Samtals} \ \cmidrule{2-3} \cmidrule{4-5} \cmidrule{6-7} \cmidrule{8-9} \cmidrule{10-11} & {Orka GWh} & {Afl MW} & {Orka GWh} & {Afl MW} & {Orka GWh} & {Afl MW} & {Orka GWh} & {Afl MW} & {Orka GWh} & {Afl MW} \

\midrule
2015\tnote{1} &amp; 3604,74 &amp; 618,46 &amp; 14356,34 &amp; 1685,89 &amp; 369,56 &amp; 57,11 &amp; 468,32 &amp; 75,40 &amp; 18798,96 &amp; 2383,25 \\
2016\tnote{1} &amp; 3383,99 &amp; 590,10 &amp; 14334,19 &amp; 1695,96 &amp; 360,42 &amp; 57,05 &amp; 470,86 &amp; 71,46 &amp; 18549,46 &amp; 2378,51 \\
2017\tnote{1} &amp; 3519,13 &amp; 608,86 &amp; 14869,95 &amp; 1750,87 &amp; 373,07 &amp; 61,49 &amp; 476,38 &amp; 84,74 &amp; 19238,53 &amp; 2443,61 \\
2018\tnote{1} &amp; 3682,07 &amp; 623,26 &amp; 15259,88 &amp; 1838,28 &amp; 398,09 &amp; 70,47 &amp; 489,75 &amp; 70,71 &amp; 19829,79 &amp; 2519,53 \\
2019\tnote{1} &amp; 3506,86 &amp; 596,63 &amp; 15145,31 &amp; 1829,48 &amp; 365,82 &amp; 63,40 &amp; 476,84 &amp; 85,11 &amp; 19494,83 &amp; 2495,07 \\
2020\tnote{1} &amp; 3473,77 &amp; 596,83 &amp; 14830,70 &amp; 1790,95 &amp; 353,09 &amp; 60,54 &amp; 469,74 &amp; 72,27 &amp; 19127,30 &amp; 2408,28 \\
2021          &amp; 3688,10 &amp; 630,47 &amp; 15539,59 &amp; 1865,64 &amp; 397,70 &amp; 67,72 &amp; 479,82 &amp; 73,82 &amp; 20105,21 &amp; 2584,89 \\
2022          &amp; 3785,98 &amp; 647,81 &amp; 16099,28 &amp; 1875,76 &amp; 416,40 &amp; 69,68 &amp; 490,14 &amp; 75,41 &amp; 20791,80 &amp; 2615,29 \\

\bottomrule \end{tabular*}

\smallskip\footnotesize \begin{tablenotes} \item[1] Rauntölur \end{tablenotes}

\end{threeparttable} \end{sidewaystable}

\end{document}

Mico
  • 506,678
1

A try to fit your table on portrait oriented page. By use of talltblr of tabularray package, which is offer functionalčity of the to classic threeparttable, with libraries booktabs and siunitx.

\documentclass[a4paper,12pt,twoside,BCOR=10mm]{scrbook}
\usepackage[icelandic]{babel}
\usepackage[T1]{fontenc}
\usepackage[dvipsnames]{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\sisetup{group-minimum-digits =4,
         group-separator      ={.},
         output-decimal-marker={,}}
\newcommand\TN[1]{\TblrNote{#1}}
\usepackage[format=plain,
            labelformat=simple,labelsep=colon]{caption}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document} \begin{table} \footnotesize \centering \SetTblrStyle{note}{font=\scriptsize} \begin{talltblr}[ caption = {Spá um raforkunotkun, forgangsorka og skerðanleg orka. Almenn notkun að meðtöldum dreifitöpum og núverandi og samþykktir nýir stórnotendur.}, label = {table:Orkuspá}, note{1} = {Rauntölur} ]{colsep = 2.9pt, colspec = {@{} l Q[c, si={table-format=4.2}] Q[c, si={table-format=3.2}] Q[c, si={table-format=5.2}] Q[c, si={table-format=4.2}] *{2}{Q[c, si={table-format=3.2}] Q[c, si={table-format=2.2}]} Q[c, si={table-format=5.2}] Q[c, si={table-format=4.2}] @{}}, row{1,2} = {guard, b}, hspan=even } \toprule \SetCell[r=2]{c} Ár & \SetCell[c=2]{c} {Úttekt frá dreifikerfinu\ forgangsog skerðanleg\ orka með dreifitöpum} & & \SetCell[c=2]{c} {Úttekt frá\ flutningskerfinu} & & \SetCell[c=2]{c} Flutningstöp & &\SetCell[c=2]{c} {Úttekt frá \ vinnslufyrir-\tækjum} & & \SetCell[c=2]{c} Samtals
& \ \cmidrule[lr=-0.4]{2-3} \cmidrule[lr=-0.4]{4-5} \cmidrule[lr=-0.4]{6-7} \cmidrule[lr=-0.4]{8-9} \cmidrule[lr=-0.4]{10-11} & {Orka\ GWh} & {Afl\ MW} & {Orka\ GWh} & {Afl\ MW} & {Orka\ GWh} & {Afl\ MW} & {Orka\ GWh} & {Afl\ MW} & {Orka\ GWh} & {Afl\ MW} \ \midrule 2015\TN{1} & 3 604,74 & 618,46 & 14 356,34 & 1 685,89 & 369,56 & 57,11 & 468,32 & 75,40 & 18 798,96 & 2 383,25 \ 2016\TN{1} & 3 383,99 & 590,10 & 14 334,19 & 1 695,96 & 360,42 & 57,05 & 470,86 & 71,46 & 18 549,46 & 2 378,51 \ 2017\TN{1} & 3 519,13 & 608,86 & 14 869,95 & 1 750,87 & 373,07 & 61,49 & 476,38 & 84,74 & 19 238,53 & 2 443,61 \ 2018\TN{1} & 3 682,07 & 623,26 & 15 259,88 & 1 838,28 & 398,09 & 70,47 & 489,75 & 70,71 & 19 829,79 & 2 519,53 \ 2019\TN{1} & 3 506,86 & 596,63 & 15 145,31 & 1 829,48 & 365,82 & 63,40 & 476,84 & 85,11 & 19 494,83 & 2 495,07 \ 2020\TN{1} & 3 473,77 & 596,83 & 14 830,70 & 1 790,95 & 353,09 & 60,54 & 469,74 & 72,27 & 19 127,30 & 2 408,28 \ 2021 & 3 688,10 & 630,47 & 15 539,59 & 1 865,64 & 397,70 & 67,72 & 479,82 & 73,82 & 20 105,21 & 2 584,89 \ 2022 & 3 785,98 & 647,81 & 16 099,28 & 1 875,76 & 416,40 & 69,68 & 490,14 & 75,41 & 20 791,80 & 2 615,29 \ \bottomrule \end{talltblr} \end{table} \end{document}

enter image description here

Zarko
  • 296,517
  • For some reason I get an error Package xcolor Error: Undefined colorguard'Myxcolor` package is set up like yours in this document... – Ólafur Víðir Guðbjargarson Apr 25 '23 at 08:35
  • @ÓlafurVíðirGuðbjargarson, I tested my <<mwe again, It works as it is. Important is, that you not change table preamble. BTW, I don't know, if hyphenation of "vinnslufyrirtækjum" is correct. It should be done manually. – Zarko Apr 25 '23 at 08:54
  • I just found out that siunitx doesn't seem to be installed through my TexLive package, Trying to figure out how to install from github, but this specific package does not include how to install (use make or run specific command). – Ólafur Víðir Guðbjargarson Apr 25 '23 at 08:57
  • @ÓlafurVíðirGuðbjargarson, siunitx is in CTAN: https://ctan.org/pkg/siunitx?lang=en . I'm not familiar with TeXLive, but it probably has a vizard for uploading of new packages. – Zarko Apr 25 '23 at 09:01
  • Yeah, I see it on CTAN, rinning linux and I am not familiar with CTAN packages or how to install them. Most of the packages I use I have found in the AUR. – Ólafur Víðir Guðbjargarson Apr 25 '23 at 09:04
  • @ÓlafurVíðirGuðbjargarson, on CTAN you can find https://ctan.org/pkg/texlive. There is some description about TeXlive. It may help you. – Zarko Apr 25 '23 at 09:09
  • @ÓlafurVíðirGuðbjargarson, BTW, check which version of tabularray you have. The last is 2023A – Zarko Apr 25 '23 at 09:19
  • I'll do that when I have cleaned installed TexLive, Doing it manually now, and will take some time. Should give me the ability to install siunitx directly from CTAN. – Ólafur Víðir Guðbjargarson Apr 25 '23 at 09:20
  • This is unfortunately not working, When I install siunitx, I get tlmgr install: package already present: siunitx but when I compile latex I get Filesiunitx.sty' not found.`. I am at a loss here – Ólafur Víðir Guðbjargarson Apr 25 '23 at 12:58
  • OK, fixed the File: siunitx.sty not found but now it won't read the numbers..... I am giving up on this. :D – Ólafur Víðir Guðbjargarson Apr 25 '23 at 13:16
  • 1
    @ÓlafurVíðirGuðbjargarson, sorry to hear this. I can't solve remotely your LaTeX installation problems. For sure the proposed solutions (as mine as of Mico) are not source of your problem . It may be a time to reinstall it or use Overleaf service. – Zarko Apr 25 '23 at 14:12
  • I know.... I have no idea why this is acting like this, but I was able to revert to last working solution. So I will use that. Thank you for your help @Zarko I am a bit sad that this method didn't work for me. – Ólafur Víðir Guðbjargarson Apr 25 '23 at 14:34
  • I noticed that in your code, the numbers are differently formatted, could that be the case? – Ólafur Víðir Guðbjargarson Apr 25 '23 at 18:37
  • 1
    @ÓlafurVíðirGuðbjargarson, no. I just test my MWE also on Overleaf. It works as expected: fine. For local compilation on your PC, apparently you need to resolve remedy in your LaTeX installation (thoroughly uninstall it and them make fresh installing). – Zarko Apr 25 '23 at 18:45
  • it's fine, just need this for my thesis. After that I'll probably make a clean install of OS and maybe latex as well. – Ólafur Víðir Guðbjargarson Apr 25 '23 at 18:53