1

first post hhere so please be gentle :) i´m writing my PhD thesis, came up with a problem in one of my longtables. basically the first column takes a lot of unused space, pushing the last two columns outside of the page margins. I can't figure out what's wrong with my code. Down below you can see my MWE. any suggestions?

\documentclass[12pt,twoside,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage[absolute,overlay]{textpos}
\usepackage{graphicx}
\usepackage{seqsplit}
\usepackage[english]{babel}
\usepackage{rotating}
\usepackage{longtable}
\usepackage{supertabular}
\usepackage{multirow}
\usepackage{siunitx}
\usepackage{tabularx}
\usepackage{afterpage}
\usepackage{multicol}
\usepackage{epsfig}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage[version=4]{mhchem}
\usepackage[numbers]{natbib}
\usepackage{xcolor}
\usepackage{ae,aecompl}
\usepackage{graphicx}
\usepackage{inputenc}
\usepackage[T1]{fontenc}
\usepackage{epsf}
\usepackage{setspace}
\usepackage{appendix}
\renewcommand{\baselinestretch}{1.5}
\usepackage{placeins}
\setlength{\textwidth}{150mm}
\setlength{\textheight}{230mm}
\setlength{\evensidemargin}{3mm}
\setlength{\oddsidemargin}{3mm}
\begin{document}
\begin{center}
    \begin{longtable}{c c c c c c c}
        \caption{Calculated and measured thin film parameters.}\\
        \hline
Sub-Film & $T_C$(K)&$ \Delta T_C$ (K)&$J_C (MA/cm^2)$& RRR &  $\Delta$ (meV) & $L_k$ ($pH/\square$)\\
\hline
\endfirsthead
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\hline
Sub-Film &   $T_C$ (K)    & $ \Delta T_C$ (K)   & $J_C (MA/cm^2)$    & RRR &  $\Delta$ (meV) & $L_k$ ($pH/\square$)\\
\hline
\endhead
\hline
\endfoot
\hline
\endlastfoot
Si-NbN15-1 & 11.2 & 0.5 & 3.25 & 0.88 & 1.71  & 28.5 \\

Si-NbN15-2 & 11   & 0.47& 3.21 & 0.88 & 1.67  & 27.4 \\

Sa-NbN15   & 13.4 & 0.18& 9.3  & 1.07 & 2.03  & 7.28 \\

Sa-NbN30   & 13.9 & 0.09& n.a.  & 1.09 & 2.11  & 3.33 \\

Sa-NbN5    & 12.48 &  0.27  & 2.28 & 0.96 & 1.89  & 30.33\\

SaAu-NbN13.3&13.04 &  0.3   & 6.65 & 1.11 & 1.98  & 7.57 \\

SaNb-NbN13.3&13.05 &  0.27  & 6.78 & 1.08 & 1.98  & 8.34 \\

SaAu-NbN25.5&13.53 &  0.18  & n.a.   & 1.12 & 2.05  & 3.76 \\

SaNb-NbN25.5&13.295&  0.2   & n.a.   & 1.1  & 2.02  & 3.96 \\

Di-NbN15    & 9.05 &  1.24  & 0.567 & 0.91 & 1.44  & 22.77\\

Di-Nb15     & 6.85 & 0.1    & n.a.   & 1.79 & 1.04  & 3.25 \\

Di-Nb30     &7.27  & 0.08   & n.a.   & 2.04 & 1.1   & 1.57
        \label{lk}
    \end{longtable}
\end{center}
\end{document}
5
  • 1
    you have put {\tablename\ \thetable\ -- \textit{Continued from previous page}} into the first column Feb 19, 2021 at 16:30
  • 2
    you could/should have removed every package not used in the example, but as they are there, please remove ae,aecomp,epsf, epsfig packages from your document, no documents written in the last 30 years should have those loaded Feb 19, 2021 at 16:34
  • suggestion duly noted and implemented. thanks!
    – Brucci0
    Feb 19, 2021 at 18:06
  • Why not just use \caption[]{ -- \textit{Continued from previous page}} \\ instead of {\tablename\ \thetable\ -- \textit{Continued from previous page}} \\ ?
    – leandriis
    Feb 19, 2021 at 18:13
  • first time i use the longtable environment, got the syntax from an example online but thanks, will try to implement everything. feel very dumb now since the solution was trivial
    – Brucci0
    Feb 19, 2021 at 18:16

1 Answer 1

0

The issue for the overly wide first column is the use of {\tablename\ \thetable\ -- \textit{Continued from previous page}} \\ which places the whole text inside of the first column. Either use a \multicolumn as in \multicolumn{7}{c}{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\ or a \caption command as in \caption{ -- \textit{Continued from previous page}} \\ .

The following MWE contains some more suggestions on how you could improve your table. For consistent units and improved alignment of numbers inside of their columns, I used siunitx. For horizontal lines with improved spacing around them, I used the booktabs package. To save some space and in order to make sure the table fits into the available textwidth, I alsi introduced linebreaks in the column headers with the help of the \thead command from makecell.

enter image description here

\documentclass[12pt,twoside,a4paper]{report}

\usepackage{longtable}
\usepackage{booktabs}
\usepackage{amssymb}
\usepackage{siunitx}
\usepackage{makecell}
\renewcommand{\theadfont}{\normalsize}
\setlength{\textwidth}{150mm}
\setlength{\textheight}{230mm}
\setlength{\evensidemargin}{3mm}
\setlength{\oddsidemargin}{3mm}

\begin{document}
\begin{longtable}{l 
                  S[table-format=2.3] 
                  S[table-format=2.2]
                  S[table-format=2.3] 
                  *{2}{S[table-format=1.2]} 
                  S[table-format=2.2]}
\caption{Calculated and measured thin film parameters.}\label{lk}\\
\toprule
Sub-Film &   {\thead{$T_C$\\ (\si{\K})}}    & {\thead{$\Delta T_C$\\ (\si{\K})}}   & {\thead{$J_C$\\ (\si{MA\per\cm\squared})}}    & {\thead{RRR}} &  {\thead{$\Delta$\\ (\si{\milli\electronvolt})}} & {\thead{$L_k$\\ ($pH/\square$)}}\\
\midrule
\endfirsthead
\caption{ -- \textit{Continued from previous page}} \\
\toprule
Sub-Film &   {\thead{$T_C$\\ (\si{\K})}}    & {\thead{$\Delta T_C$\\ (\si{\K})}}   & {\thead{$J_C$\\ (\si{MA\per\cm\squared})}}    & {\thead{RRR}} &  {\thead{$\Delta$\\ (\si{\milli\electronvolt})}} & {\thead{$L_k$\\ ($pH/\square$)}}\\
\midrule
\endhead
\bottomrule
\endfoot
\bottomrule
\endlastfoot
Si-NbN15-1 & 11.2 & 0.5 & 3.25 & 0.88 & 1.71  & 28.5 \\

Si-NbN15-2 & 11   & 0.47& 3.21 & 0.88 & 1.67  & 27.4 \\

Sa-NbN15   & 13.4 & 0.18& 9.3  & 1.07 & 2.03  & 7.28 \\

Sa-NbN30   & 13.9 & 0.09& {n.a.}  & 1.09 & 2.11  & 3.33 \\

Sa-NbN5    & 12.48 &  0.27  & 2.28 & 0.96 & 1.89  & 30.33\\

SaAu-NbN13.3&13.04 &  0.3   & 6.65 & 1.11 & 1.98  & 7.57 \\

SaNb-NbN13.3&13.05 &  0.27  & 6.78 & 1.08 & 1.98  & 8.34 \\

SaAu-NbN25.5&13.53 &  0.18  & {n.a.}   & 1.12 & 2.05  & 3.76 \\

SaNb-NbN25.5&13.295&  0.2   & {n.a.}   & 1.1  & 2.02  & 3.96 \\

Di-NbN15    & 9.05 &  1.24  & 0.567 & 0.91 & 1.44  & 22.77\\

Di-Nb15     & 6.85 & 0.1    & {n.a.}   & 1.79 & 1.04  & 3.25 \\

Di-Nb30     &7.27  & 0.08   & {n.a.}   & 2.04 & 1.1   & 1.57\\
        
    \end{longtable}
\end{document}
3
  • thank you very much, leandris! looks defo better, will use your code in my main tex and also will try to clean it from useless packages to streamline it. much appreciated! take care.
    – Brucci0
    Feb 20, 2021 at 11:34
  • @Brucci0: If you like my answer and it was helpful, please consider upvoting (by clicking on the arrows next to the score) and/or marking it as the accepted answer (by clicking on the checkmark ✓).
    – leandriis
    Feb 20, 2021 at 16:29
  • yeah sure no problem! i'm new to SE and still tryiing to wrap my head around the mechanics of the whole site ;)
    – Brucci0
    Feb 22, 2021 at 8:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .