1

Subj.

I cannot use singlelinecheck=off because it aligns it to the left border of the page. And why table is too narrow?

\documentclass[12pt,a4paper,oneside]{article}
\usepackage[left=35mm,right=15mm,top=2cm,bottom=2cm,bindingoffset=0cm]{geometry}
\usepackage[utf8x]{inputenc} % указать кодировку русского текста
\usepackage[russian]{babel} % указать, что язык текста - русский

\usepackage{cmap}

\usepackage{makeidx}
\makeindex

\usepackage{indentfirst} 
\setlength{\parindent}{1.25cm}

\usepackage{caption}
\captionsetup[table]{labelsep=endash}

\usepackage{ltablex}
\usepackage{lipsum}
\begin{document}
    \keepXColumns
        \begin{tabularx}{\textwidth}{| l | X |} 

        \caption{A long description of this awesomest table ever. No, seriously.}\\
        \hline 
        First & Second\\ \hline \hline
        \endfirsthead
        \captionsetup{singlelinecheck=off}
        \caption{A short one}\\
        \hline 
        First & Second\\ \hline
        \endhead
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        \end{tabularx}
\end{document}
0

2 Answers 2

1

I don't know why the table doesn't stretch. But here's an alternative, replacing ltablex with the more recent longtabu environment. Another longtabu example directly compared to an ltablex one can be found in the answer to Ltablex customize caption.

\documentclass[12pt,a4paper,oneside]{article}
\usepackage[left=35mm,right=15mm,top=2cm,bottom=2cm,bindingoffset=0cm]{geometry}
\usepackage[utf8x]{inputenc} % указать кодировку русского текста
\usepackage[russian]{babel} % указать, что язык текста - русский

\usepackage{cmap}

\usepackage{makeidx}
\makeindex

\usepackage{indentfirst} 
\setlength{\parindent}{1.25cm}

\usepackage{caption}
\captionsetup[table]{labelsep=endash}

\usepackage{longtable}
\usepackage{tabu}
\usepackage{lipsum}
\begin{document}
%    \keepXColumns
        \begin{longtabu} to \textwidth {| l | X |} 

        \caption{A long description of this awesomest table ever. No, seriously. Worth repeating: A long description of this awesomest table ever. No, seriously. }\\
        \hline 
        First & Second\\ \hline \hline
        \endfirsthead
        \captionsetup{singlelinecheck=off}
        \caption{A short one}\\
        \hline 
        First & Second\\ \hline
        \endhead
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        \end{longtabu}
\end{document}
1

You are using {|l|X|}. Instead if you use {|X|X|}, you will get two columns of equal width and table spans the text width. But the table will look ugly in that case. Hence you may try something like \begin{tabularx}{\textwidth}{|l|p{.89\textwidth}|}.

Your first point is not so clear. You don't want to have the cption to be aligned at left margin? In such case you can put \captionsetup{singlelinecheck=off,margin=0cm}. You can play with the margin value as your wish.

The MWE:

\documentclass[12pt,a4paper,oneside]{article}
\usepackage[left=25mm,right=15mm,top=2cm,bottom=2cm,bindingoffset=0cm]{geometry}
\usepackage[utf8x]{inputenc} % указать кодировку русского текста
\usepackage[russian]{babel} % указать, что язык текста - русский

\usepackage{cmap}

\usepackage{makeidx}
\makeindex

\usepackage{indentfirst}
\setlength{\parindent}{1.25cm}

\usepackage{caption}
\captionsetup[table]{labelsep=endash}
\usepackage{ltablex}
\usepackage{lipsum}
\begin{document}
%     \keepXColumns
        \begin{tabularx}{\textwidth}{|l|p{.89\textwidth}|}
                \captionsetup{singlelinecheck=off,margin=0cm,format=hang} %% Try format=hang for a change
        \caption{A long description of this awesomest table ever. No, seriously.}\\
        \hline
        First & Second\\ \hline \hline
        \endfirsthead

        \caption{A short one}\\
        \hline
        First & Second column of the table\\ \hline
        \endhead
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        Lols & \lipsum[150] \\ \hline
        \end{tabularx}
\end{document}

You must log in to answer this question.

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