0

I’ve always used tabularx without any problem, but now out of nothing it doesn’t make \textwidth anymore and I don't understand why (last time I opened my document, everything was fine). Could you tell me please what’s the problem?

\documentclass[a4paper, 11pt, pointlessnumbers, xcolor=dvipsnames]{scrreprt}

\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage{latexsym}
\usepackage{tabularx}
\usepackage{ltablex}
\usepackage{amssymb}
\usepackage{booktabs}

\babeltags{ger=ngerman}

\usepackage{array, booktabs, boldline}

\begin{document}
\noindent
\def\arraystretch{1.5}
\begin{tabularx}{\textwidth}{>{\raggedright\arraybackslash}p{2.5cm}>{\raggedright\arraybackslash}X>{\raggedright\arraybackslash}X>{\raggedright\arraybackslash}X}
\hlineB{2}
\textsf{\textbf{Addition}} & Avant tout & Ensuite & Pour conclure \\
\hlineB{2}
\end{tabularx}

\end{document}

5
  • What exactly do you mean by does not work anymore? Do you get an error? If so please cite this error in your question.
    – daleif
    Jul 30 at 10:11
  • tabularx doesn’t make the table as wide as the page is. So \textwidth doesn’t work (thanks for the remark, I’ve edited my post). Jul 30 at 10:16
  • 1
    Why are you loading ltablex? If ltablex is removed it works as it should, so it more seems appropriate to change the title to be about ltablex
    – daleif
    Jul 30 at 10:20
  • 1
    From manual: "In other words, the specified width is treated as the maximum allowed and not the exact width of the table.". Make your example minimal by removing unused packages,... Jul 30 at 10:23
  • also you have a space to the left of tabularx from the space after 1.5} Jul 30 at 10:31
1
  • Your document example can be compile without any error or warnins, i.e. it works as expected

  • You should be aware, that ltablex has a features that in cases, when contents in columns are shorter as would be at X column when only tabularx is loaded, reduce their width to natural width of columns contents (what happens in your case).

  • Your problems can be solved on two ways:

    • from preamble remove the ltablex package and use some other package which combine longtable and tabularx, for example xltabular
    • if for some reason you need to use ltablex, than add \keepXColumns to document preamble:
\documentclass[a4paper, 11pt, pointlessnumbers, xcolor=dvipsnames]{scrreprt}
%---------------- Show page layout. Don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage{amssymb, latexsym}
\usepackage{boldline, ltablex}
\newcolumntype{L}{ >{\raggedright\arraybackslash}X}
\keepXColumns

\babeltags{ger=ngerman}


\begin{document}
\noindent
\def\arraystretch{1.5}
\begin{tabularx}{\textwidth}{>{\raggedright\arraybackslash}p{2.5cm}
                             LLL}
\hlineB{2}
\textsf{\textbf{Addition}} & Avant tout & Ensuite & Pour conclure \\
\hlineB{2}
\end{tabularx}

\end{document}

enter image description here

(red lines indicate text borders)

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.