3

I need a table that starts right at the point I need it to be and I have no problem if it span across pages. So I have used longtable but it is giving erroneous output as shown in photo attached with this question.

\documentclass{report}
\usepackage{longtable}
\usepackage{nicefrac}
\usepackage{amsmath}

\begin{document}
    \chapter{Sample Chapter}
        \section{Sample Section}
            \subsection{Chain}
                    \begin{longtable}{|p{.4\textwidth}|p{.6\textwidth}|}
                        %\centering
                        \label{table:chain}
                        \caption{Specifications of Chain Used}
                        %\endfirsthead 
                        \hline
                        Type & Transmission roller chain – British Standard DIN 8187 ISO/R 606\\ \hline
                        ISO Standard & 06 B2\\ \hline
                        Standard Size & $\nicefrac{3}{8}" \times \nicefrac{7}{32}"$\\ \hline
                        Pitch $(p)$ & $9.53mm$\\ \hline
                        Inner Width $(b_1)$ & $5.72mm$\\ \hline
                        Roller Diameter $(D_r)$ & $6.53mm$\\ \hline
                        Pin Diameter $(D_p)$ & $3.28mm$\\ \hline
                        Min. Ultimate Strength & $16.000N$\\ \hline
                        Weight & $0.78Kg/m$ 
                        \\ \hline %
                        
                    \end{longtable}
\end{document}

I am also getting some errors:

Misplaced \noalign. \caption

Misplaced \omit. \caption{Specifications of Chain Used}

Misplaced \noalign. \hline

Misplaced \omit. T

Extra alignment tab has been changed to \cr. T

image1

If I uncomment the \endfirsthead, then output is as in second picture. image2

One thing to note is that I did not get any output untill I first commented out both \label and \caption. After first commenting both these gave me correct output without caption, then when I uncommented these it gives this output.

4
  • 3
    Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.
    – Thruston
    Apr 5, 2017 at 12:22
  • Unrelated, but \label should appear after \caption, not before; please consider to typeset the various units in your table with siunitx as well
    – user31729
    Apr 5, 2017 at 12:22
  • 2
    The real error is a missing \endfirsthead after \caption
    – user31729
    Apr 5, 2017 at 12:26
  • @Thruston Edited the code. Thanks for suggesting it. Apr 5, 2017 at 12:48

1 Answer 1

5

Either use a \endfirsthead, \endhead or just a \tabularnewline after \caption{...}\label{},

otherwise \hline or any other of the \...rule commands do not work, they must start at the beginning of the line, which is not the case without \tabularnewline etc.

I also 'slightly' modified the table with booktabs and removed the unpleasant vertical lines, as well introduced typesetting of the units with siunitx.

\documentclass{report}
\usepackage{longtable}
\usepackage{nicefrac}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{siunitx}


\begin{document}

\chapter{Foo chapter}
\section{Foo section}

\subsection{Chain}
\begin{longtable}{p{.35\textwidth}p{.55\textwidth}}
  % \centering
  \caption{Specifications of Chain Used}    \label{table:chain}
  \endfirsthead
  \toprule
  Type & Transmission roller chain – British Standard DIN 8187 ISO/R 606\\
  \midrule
  ISO Standard & 06 B2\\

  Standard Size & $\nicefrac{3}{8}" \times \nicefrac{7}{32}"$\\

  Pitch $(p)$ & \SI{9.53}{\milli\meter}\\

  Inner Width $(b_1)$ & \SI{5.72}{\milli\meter}\\

  Roller Diameter $(D_r)$ & \SI{6.53}{\milli\meter}\\

  Pin Diameter $(D_p)$ & \SI{3.28}{\milli\meter}\\

  Min. Ultimate Strength & \SI{16.000}{\newton}\\

  Weight & \SI{0.78}{\kilo\gram/\meter}\\
\bottomrule
\end{longtable}

\end{document}

enter image description here

4
  • 1
    Thanks @Christian Hupfer, you did more than I was expecting. Apr 5, 2017 at 12:58
  • @GaurishGangwar: Thanks, you're welcome. Happy TeXing!
    – user31729
    Apr 5, 2017 at 13:02
  • 1
    I would remove all \hrule commands between ordinary rows and end the table with \bottomrule to represent the table much more clearly. Apr 7, 2017 at 12:32
  • @HeikoOberdiek: Thanks, it looks better then, I've updated
    – user31729
    Apr 7, 2017 at 13:38

You must log in to answer this question.

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