1

i made a table to be inserted in a paper, where it works, and i moved it to my thesis. For some reasons it gives me a series of errors i cannot understand, can you help me? i tried copying the various package i have in my thesis tex and the table code here

\ifsetCustomMargin
  \RequirePackage[left=37mm,right=30mm,top=35mm,bottom=30mm]{geometry}
  \setFancyHdr

\RequirePackage[labelsep=space,tableposition=top]{caption}
\renewcommand{\figurename}{Fig.}

\usepackage{float}
\restylefloat{figure}

\usepackage{subcaption}

\usepackage{booktabs} % For professional looking tables
\usepackage{multirow}

\usepackage{multicol}
\usepackage{longtable}
\usepackage{tabularx}
\usepackage[utf8]{inputenc}
 \usepackage{makecell}
\usepackage{longtable}
\usepackage{ltablex}
\newcommand{\tabitem}{~~\llap{\textbullet}~~}

\usepackage{siunitx}
\ifuseCustomBib
   \RequirePackage{natbib}


\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}



\begin{table}
    \caption{Example of different attributions by three representative participants (A, B and C)}
    \label{table3}
    \setcellgapes{5pt}
    \makegapedcells
    \centering
    \begin{tabularx}{\linewidth}{*{6}{>{\raggedright\arraybackslash}X}}
        \hline
        \textbf{Part A} & \textit{Sally speaking} & \textit{Narrator} & \textit{Sally speaking} & \textit{Narrator} & \textit{Sally speaking} \\
        \cline{2-6}
        & Oh yes, & Sally remembered; & she had it still, a ruby ring which Marie Antoinette had given her great-grandfather. & She never had a penny to her name in those days & and going to Bourton always meant some frightful pinch.\\
        \hline
        \textbf{Part B} & \multicolumn{5}{l}{\textit{Sally thinking}} \\
        \cline{2-6}
        & \multicolumn{5}{l}{Oh yes, Sally remembered; she had it still, a ruby ring which Marie} \\
        & \multicolumn{5}{l}{Antoinette had given her great-grandfather}
        \hline
    \end{tabularx}

\end{table}

I also attach a capture of the errors i getenter image description here

2
  • Welcome to TeX LaTeX SX! Could you post a compilable code?
    – Bernard
    Nov 1 '17 at 11:34
  • 2
    the last row should be ended by ` \\ ` ...
    – Zarko
    Nov 1 '17 at 11:35
1

All \hlines in a tabular should be preceded by a \\ as stated by @Zarko in a comment. I also changed the first column alignment to l as it's shorter than all other columns.

\begin{table}
    \caption{Example of different attributions by three representative participants (A, B and C)}
    \label{table3}
    \setcellgapes{5pt}
    \makegapedcells
    \centering
    \begin{tabularx}{\linewidth}{@{}l*{5}{>{\raggedright\arraybackslash}X}@{}}
        \hline
        \textbf{Part A} & \textit{Sally speaking} & \textit{Narrator} & \textit{Sally speaking} & \textit{Narrator} & \textit{Sally speaking} \\
        \cline{2-6}
        & Oh yes, & Sally remembered; & she had it still, a ruby ring which Marie Antoinette had given her great-grandfather. & She never had a penny to her name in those days & and going to Bourton always meant some frightful pinch.\\
        \hline
        \textbf{Part B} & \multicolumn{5}{l}{\textit{Sally thinking}} \\
        \cline{2-6}
        & \multicolumn{5}{l}{Oh yes, Sally remembered; she had it still, a ruby ring which Marie} \\
        & \multicolumn{5}{l}{Antoinette had given her great-grandfather} \\
        \hline
    \end{tabularx}    
\end{table}

enter image description here

1

You're forgetting \\ before \hline. On the other hand, some improvements can be made on your code, for instance how to get a better \multicolumn for the spanned columns in part B.

\documentclass{article}
\usepackage{microtype}
\usepackage{tabularx,booktabs}

\begin{document}

\begin{table}
\caption{Example of different attributions by three representative participants (A, B and C)}
\label{table3}

\centering

\begin{tabularx}{\linewidth}{
  @{}
  l
  *{5}{>{\raggedright\arraybackslash}X}
  @{}
}
\toprule
\textbf{Part A}
  & \textit{Sally speaking}
  & \textit{Narrator}
  & \textit{Sally speaking}
  & \textit{Narrator}
  & \textit{Sally speaking} \\
\cmidrule(l){2-6}
  & Oh yes,
  & Sally remembered;
  & she had it still, a ruby ring which Marie Antoinette
    had given her great-grandfather.
  & She never had a penny to her name in those days
  & and going to Bourton always meant some frightful pinch.\\
\midrule
\textbf{Part B}
  & \multicolumn{5}{l}{\textit{Sally thinking}} \\
\cmidrule(l){2-6}
  & \multicolumn{5}{>{\raggedright\arraybackslash\hsize=\dimexpr5\hsize+8\tabcolsep}X@{}}{%
      Oh yes, Sally remembered; she had it still, a ruby ring which
      Marie Antoinette had given her great-grandfather} \\
\bottomrule
\end{tabularx}    

\end{table}

\end{document}

enter image description here

0

let me elaborate my comment ...

for reproduce your problem it is sufficient the following minimal working example (mwe) :

\documentclass{article}
\usepackage{makecell, tabularx}

\begin{document}
\begin{table}
    \setcellgapes{5pt}
    \makegapedcells
    \caption{Example of different attributions by three representative participants (A, B and C)}
    \label{table3}
    \centering
    \begin{tabularx}{\linewidth}{*{6}{>{\raggedright\arraybackslash}X}}
        \hline
\textbf{Part A} & \textit{Sally speaking} & \textit{Narrator} & \textit{Sally speaking} & \textit{Narrator} & \textit{Sally speaking} \\
        \cline{2-6}
        & Oh yes, & Sally remembered; & she had it still, a ruby ring which Marie Antoinette had given her great-grandfather. & She never had a penny to her name in those days & and going to Bourton always meant some frightful pinch.\\
        \hline
\textbf{Part B} & \multicolumn{5}{l}{\textit{Sally thinking}} \\
        \cline{2-6}
        & \multicolumn{5}{l}{Oh yes, Sally remembered; she had it still, a ruby ring which Marie} \\
        & \multicolumn{5}{l}{Antoinette had given her great-grandfather}
        \hline
    \end{tabularx}
\end{table}
\end{document}

where the last row is nod ended with \\. it is necessary when after rows you have any of rules (\hline, \cline, etc).

corrected and slightly improved mwe can be as follows:

enter image description here

since in your code is booktabs package, it is sensible to use it as is shown in AboAmmar answer.

\documentclass{article}
\usepackage{geometry}
\usepackage[utf8]{inputenc}

\usepackage{ragged2e}
\usepackage{makecell, tabularx}
%    \renewcommand\theadfont{\itshape}
    \newcolumntype{L}{>{\RaggedRight}X}

\begin{document}


\begin{table}
    \setcellgapes{5pt}
    \makegapedcells
    \setlength\tabcolsep{3pt}
    \caption{Example of different attributions by three representative participants (A, B and C)}
    \label{table3}
    \centering
    \begin{tabularx}{\linewidth}{@{}
                            >{\bfseries}l
                                   *{5}{L}
                                @{} }
        \hline
Part A
    &   \textit{Sally speaking}
        &   \textit{Narrator}
            &   \textit{Sally speaking}
                &   \textit{Narrator}
                    &   \textit{Sally speaking}                               \\
        \cline{2-6}
    &   Oh yes,
        &   Sally remembered;
            &   she had it still, a ruby ring which Marie Antoinette had given her great-grandfather.
                &   She never had a penny to her name in those days
                    &   and going to Bourton always meant some frightful pinch. \\
        \hline
Part B
    &   \multicolumn{5}{l}{\textit{Sally thinking}}                             \\
        \cline{2-6}
    &   \multicolumn{5}{l}{Oh yes, Sally remembered; she had it still, a ruby ring which Marie} \\
    &   \multicolumn{5}{l}{Antoinette had given her great-grandfather}          \\
        \hline
    \end{tabularx}

\end{table}
    \end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.