0

Is there a way to mimic this MWE, but using the long table approach?

\documentclass{article}

\usepackage{table, tabular}

\begin{table}[!htbp]
\setlength\tabcolsep{.25cm}
\renewcommand{\arraystretch}{1}
\caption{Parameter description\strut}
\centering

\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} ll@{}}

\toprule

\multicolumn{1}{@{}l}{{\color{blue} \textsc{Parameter}}} & \multicolumn{1}{l}{{\color{blue} \textsc{Description}}} \\

\midrule

\bottomrule 

\end{tabular*}
\end{table}

\end{document}
3
  • 3
    Please, as usual, make your code snippet be compilable to become an MWE ...
    – Mensch
    Aug 5 at 10:48
  • this example produces the error ! LaTeX Error: File `table.sty' not found. unless you are asking about that error, you should change the example. Aug 5 at 15:31
  • Sorry, but with last edit you change question so much, that you nullify received answers. If you have new problems, it will be fer to ask new question where you should provide MWE, which reproduce your problem. In its preparing you can use MWE from suggestion in received answers.
    – Zarko
    Aug 7 at 7:57

2 Answers 2

2
  • It is not entirely clear how should long table looks ...
  • Also you not give any tip, about content of your table.
  • Without coloring the first row, and columns types as you have in your tabular table:
\documentclass{article}
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%
\usepackage{lipsum}                             % for dummy text
%---------------------------------------------------------------%

\usepackage{booktabs, longtable}

\begin{document}
\lipsum[1-4]

\begingroup
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\begin{longtable}{ @{\extracolsep{\fill}} ll @{} } 
%
\caption{Parameter description}
\label{tab: ???}                                    \\
    \toprule
    \textsc{Parameter}  &  \textsc{Description}     \\
    \midrule
\endfirsthead
\caption[]{Parameter description (continue)} \\
    \toprule
    \textsc{Parameter}  &  \textsc{Description}     \\
    \midrule
\endhead
    \midrule
    \multicolumn{2}{r}{\footnotesize\textit{Continued on the next page}}
\endfoot
    \bottomrule
\endlastfoot
%
some text           &   some longer text    \\
some long  long  
long text           &   some text           \\
some text           &   some long  long  
                        long  long  text    \\
long text           &   some text           \\
some text           &   some long  long
                        long  long  text    \\
long text           &   some text           \\
\end{longtable}
\endgroup
\lipsum[6-7]
\end{document}

enter image description here

But, as can be concluded from table caption, your table probably has narrower column with some variables in math mode and wider second column with description, i.e.: it can be something like this:

enter image description here

This can be obtain by use of the xltabular package:

\documentclass{article}
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%
\usepackage{lipsum}                             % for dummy text
%---------------------------------------------------------------%

\usepackage{booktabs, xltabular}

\begin{document}
\lipsum[1-4]

\noindent%
\begin{xltabular}{\linewidth}{ @{} >{$}l<{$} X @{} } 
%
\caption{Parameter description}
\label{tab: ???}                                    \\
    \toprule
    \textsc{Parameter}  &  \textsc{Description}     \\
    \midrule
\endfirsthead
\caption[]{Parameter description (continue)} \\
    \toprule
    \textsc{Parameter}  &  \textsc{Description}     \\
    \midrule
\endhead
    \midrule
    \multicolumn{2}{r}{\footnotesize\textit{Continued on the next page}}
\endfoot
    \bottomrule
\endlastfoot
%
x           &   some longer text    \\
y           &   some text           \\
z           &   \lipsum[66]         \\
\alpha      &   some text           \\
\beta       &   some long teyt         \\
\gamma      &   some text           \\
\end{xltabular}
\lipsum[6-7]
\end{document}

Addendum: Shorter code, which also enable simple coloring of the first row in table, you cam make by use of the tabularray package (in MWE below is used version 2022C):

\documentclass{article}
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%
\usepackage{lipsum}                             % for dummy text
%---------------------------------------------------------------%

\usepackage{colortbl}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}

\begin{document}
\lipsum[1-4]

\noindent%
    \begin{longtblr}[
caption = {Parameter description},
  label = {tab: ???},                              
                    ]{colspec = { @{} Q[l, mode=math] X[l] @{} },
                      row{1}  = {font=\scshape, mode=text, bg=blue!30},
                      rowhead = 1
                     }
    \toprule
Parameter   &   Description         \\
    \midrule
x           &   some longer text    \\
y           &   some text           \\
z           &   \lipsum[66]         \\
\alpha      &   some text           \\
\beta       &   some long teyt      \\
\gamma      &   some text           \\
    \bottomrule
\end{longtblr}
\lipsum[6-7]
\end{document}

enter image description here

(red lines in above images indicate page layout)

1

I'd suggest longtblr as probably the easiest solution (see @Zarko's answer).

In case you can't add it in your project, xltabular is an option due to its X column-type, which has a perfect use case in this kind of tables where one small column is for numbers, symbols and the other for description. X indicates to calculate the remaining space for the column, here for description, or in case of multiple Xs, it splits evenly the available space over a number of columns. Note that X is also available in longtblr environment.

The full example using xltabular. Note the usage of \endfirsthead, \endhead, \endfoot and \endlastfoot to specify what should be displayed on the first and every other page and where.

enter image description here

EDIT. In case you prefer justified text, remove the part >{\RaggedRight\arraybackslash} from the line

>{\RaggedRight\arraybackslash}X
\documentclass{article}
\usepackage{geometry}     % For a customised document layout
\usepackage{colortbl}     % Adds colo(u)rs to tables
\usepackage{booktabs}
\usepackage{caption}      % Improved captions
    \captionsetup[table]{skip=6pt, format=hang, position=above}
\usepackage{xltabular}    % A long table with X column-type
\usepackage{microtype}    % These both packages are added for improved
\usepackage{ragged2e}     %    typeset in narrow environments

%%% Added only for dummy texts and can be removed
\usepackage{kantlipsum}
\usepackage{lipsum}
%%% END

\NewExpandableDocumentCommand\ctitle{O{l}m}{%
    \multicolumn{1}{@{}#1}{\textcolor{blue}{\textsc{#2}}}}


\begin{document}
\kant[50]

\bgroup
    \kantdef{\longcaptiontitle}{100}[1]
    \setlength\tabcolsep{3pt}
    \setlength{\LTcapwidth}{0.7\linewidth}
    % \renewcommand{\arraystretch}{1.0}
    \begin{xltabular}{0.8\linewidth}{
            @{}
            >{\centering\arraybackslash\(}p{2cm}<{\)}
            >{\RaggedRight\arraybackslash}X   % remove >{...} to keep text justified 
            @{}
        }
        % The very first heading
        \caption{\longcaptiontitle} \\
        \toprule\ctitle{Parameter} & \ctitle[c]{Description} \\
        \midrule \endfirsthead
        
        % Other heading on consecutive pages
        \caption{\longcaptiontitle{} (\textit{Continued)}} \\
        \toprule\ctitle{Parameter} & \ctitle[c]{Description} \\
        \midrule \endhead
        
        % Annotation under the table on consecutive pages
        \bottomrule \addlinespace[2pt]
        \multicolumn{2}{r@{}}{\textit{Continues on the next page \dots}} \endfoot
        
        % Annotation on the row below the table
        \bottomrule \endlastfoot
        
        \alpha & \kant*[1][1] \\
        \beta & \kant*[2][1] \\
        \gamma & \kant*[3][1] \\
        \delta & \kant*[4][1] \\
        \varepsilon & \kant*[5][1] \\
        \eta & \kant*[6][1] \\
        \theta & \kant*[7][1] \\
        \omega & \kant*[8][1] \\
        \alpha & \kant*[1][1] \\
        \beta & \kant*[2][1] \\
        \gamma & \kant*[3][1] \\
        \delta & \kant*[4][1] \\
    \end{xltabular}
\egroup

\kant[51][1-3]
\end{document}
1
  • Great solution! Thanks
    – Sean
    Aug 7 at 6:54

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.