1

When I write a longtable I get a doubleenter image description here horizontal line as shown in pictute:

the code is :

\documentclass{article}
\usepackage{longtable}

\begin{document}
\begin{longtable}[htb]{p{0.22\linewidth}p{0.5\textwidth}p{.2\textwidth}}
    \caption{my table}\\ \hline
    \multicolumn{1}{c}{\textbf{Starting material}} &
    \multicolumn{1}{c}{\textbf{Finding}} & \multicolumn{1}{c}{\textbf{Author}}\\ \hline
    \endfirsthead 
    %\vspace{-0.5\baselineskip}
    \caption[]{Continue} 
    \endhead \\ \hline

    Silver nitrate (AgNO3) polyvinylpyrrolidone & \vspace{-0.6\baselineskip}
    \begin{itemize}[noitemsep,labelsep=1ex,leftmargin=*,topsep=0pt,partopsep=0pt]%itemsep=-1ex, label
        \item The structural analysis showed that synthesized material is face-centered cubic (fcc) and monodispersed within the PVP matrix with an average size of 22 nm.
        \item The UV–vis spectrum of AgNPs in visible light region revealed that the peak at 406 nm is very broad, and significant absorption exists at >500 nm, all consistent with an aggregated silver solution. 
        \item The AgNPs film has good sensitivity in the range of 50–1200 ppm at room temperature accompanying increase of gas concentration and temperature.
    \end{itemize} \vspace{-\baselineskip}&  Kumar \\ \hline
e &r&s\\


\end{longtable}
\end{document}
6
  • just delete the \\ \hline you have at the start of the table Commented Dec 15, 2020 at 2:13
  • I tried before, does not work.
    – Ayad M.
    Commented Dec 15, 2020 at 5:49
  • "does not work" is not something anyone can debug. What did you do and what error did you get? Your output shows a spurious blank line and a spurious horizontal rule as your table after the \endhead contains a spurious \\ and a spurious \hline if you remove them the corresponding output will go. Commented Dec 15, 2020 at 7:53
  • also your example produces ! LaTeX Error: Something's wrong--perhaps a missing \item. Commented Dec 15, 2020 at 7:54
  • Thank you, @DavidCarlisle, for your interest, Actually, I have not Error Just what I posted, I need to remove the line ... by the way if I want to set on all the boarder lines, how can I? Thanks a lot.
    – Ayad M.
    Commented Dec 15, 2020 at 13:51

1 Answer 1

2

Your code fragment has many issues. As @David Carlisle noted, your problem is caused by wrong position of the line terminator after \endfirsthead (see MWE below). Other issues are mainly off-topic since you not provide MWE (Minimal Working Example) a small but complete document document, which we can test. Consequently I added preamble to your code fragment according to my way of writing tables:

\documentclass{article}
\usepackage{array, booktabs,    % new
            longtable,
            makecell}           % new
\renewcommand\theadfont{\normalsize\bfseries}   % new
\renewcommand\theadgape{}                       % new
\usepackage[skip=1ex]{caption}                  % new
\usepackage[version=4]{mhchem}                  % new
\usepackage{siunitx}                            % new
\sisetup{range-phrase = -- ,
         range-units = single}
\usepackage{enumitem}                           % new
\usepackage{etoolbox}                           % new
\AtBeginEnvironment{longtable}{% new
\setlist[itemize]{nosep,
                 leftmargin=*,
                 label=\textbullet,
                 before=\begin{minipage}[t]{\linewidth}, 
                 after=\end{minipage}}
\setlength\tabcolsep{3pt}                   

\usepackage{lipsum}% for generating dummy text in table

\begin{document}
\begin{longtable}{@{}
        >{\raggedright\arraybackslash}p{\dimexpr 0.30\linewidth-\tabcolsep}     % changed
        >{\raggedright\arraybackslash}p{\dimexpr 0.50\textwidth-2\tabcolsep}    % changed
        >{\raggedright\arraybackslash}p{\dimexpr 0.20\textwidth-\tabcolsep}     % changed
                 @{}}
    \caption{My table}              
    \label{tab:longtable}               \\ 
    \toprule                                            % changed
    \thead{Starting\\ material}                         % changed
        &   \thead{Finding}
            &   \thead{Author}          \\ 
    \midrule
\endfirsthead
    \caption[]{My table -- Continue}    \\  % error was here
    \toprule
    \thead{Starting\\ material}
        &   \thead{Finding}
            &   \thead{Author}          \\
    \midrule
    \addlinespace[-3pt]
\endhead 
    \multicolumn{3}{r}{\footnotesize\textit{Continue on the next page}} % new
\endfoot                                    % new
    \bottomrule                             % new
\endlastfoot                                % new
% table body
    Silver nitrate (\ce{AgNO3}) polyvinylpyrrolidone 
        &   \begin{itemize}
        \item   The structural analysis showed that synthesized material is face-centered cubic (fcc) and monodispersed within the PVP matrix with an average size of 22 nm.
        \item   The UV–vis spectrum of \ce{AgNPs} in visible light region revealed that the peak at \SI{406}{nm} is very broad, and significant absorption exists at \SI{>500}{nm}, all consistent with an aggregated silver solution.
        \item   The \ce{AgNPs} film has good sensitivity in the range of \SIrange{50}{1200}{ppm} at room temperature accompanying increase of gas concentration and temperature.
            \end{itemize}
            &   Kumar               \\
e   &   r   &   s                   \\
    \addlinespace
e   & \lipsum[11]   &   s                   \\
\end{longtable}
\end{document}

enter image description here

enter image description here

(red lines indicate page layout)

3
  • Thank you very much @Zarko for your help, excuse me for absence of the preamble of my code, it is so huge and fragmented over on Huge file of (the thesis), but what you guested is a brief and fulfil. I have one more question, if you never mind, how to set all the boarder lines on ? Thanks in advance.
    – Ayad M.
    Commented Dec 15, 2020 at 14:00
  • @AyadM, what you mean with "how to set all the boarder lines on"? PČease clarify!
    – Zarko
    Commented Dec 15, 2020 at 14:42
  • I mean how to make a table with all boarders visible lines, for each cell. Sure with using long table.
    – Ayad M.
    Commented Dec 25, 2020 at 15:49

You must log in to answer this question.

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