1

Update : the problem has been solved by adding \shorthandoff{:} before and \shorthandon{:} after the xltabular environment (thank you Jasper). The issue was caused because of the use uf the french language automatically adding a space before semicolons.



This post is very long so I can fully explain the problem I am encountering, please feel free to correct and edit anything and/or comment. I will answer to every question I know the answer of.

TeX infos : I compile with PDFLaTeX, write under TeXMaker, and the version is 3.141592653-2.6-1.40.25


So I have a table made with xltabular in which I am using a \mulicolumn command. As many other users, I am observing a small unwanted indent on the first line of this table. I have been browsing the forum for a week now, without finding the solution to my problem. Here are the questions/answers I have been applying to my code so far :

  • egreg and Karl Hagen's solutions to this question : add @{} and/or \dimexpr and \tabcolsep. Addding one or the other or both does not get the indent off of my document, whatever the length in the command or the number of \tabcolsep. Also the same solutions are provided here. Those are not solving it.
  • Xu Wang's question and Werner's solution to this problem : add a \noindent at the beginning of the table's line. No change whatsoever in the document on my side.
  • All solutions to this question : \noindent before \begin{xltabular} ; the flushleft environment ; \setlength{\parindent}{0pt} ; etc. : no change either.
  • The \ignorespaces from here, no change.

So I started wrinting my MWE, with theoretically only the needed packages, to show you my best try and what I had tried so far, but the output was slightly different, because no indentation appeared :

\documentclass[11pt,fleqn,french]{report}

\usepackage{geometry}                               
\geometry{a4paper}

\usepackage[utf8]{inputenc}
\usepackage[OT1]{fontenc} 

\usepackage{makecell,hhline,longtable}
\usepackage[longtable]{multirow}

\usepackage{xltabular}
\renewcommand\tabularxcolumn[1]{m{#1}}

\newcolumntype{L}[1]{>{\raggedright\arraybackslash}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}m{#1}}

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%

\begin{document}

\begin{center}
\begin{xltabular}{0.75\linewidth}{|c|L{40mm}@{}L{2mm}L{15mm}|}
\hhline{|t:====:t|}
\multicolumn{1}{|c|}{\textbf{Part}} &   \multicolumn{3}{c|}{\textbf{Data}}  \endfirsthead \hline
Material \textit{$\alpha$}          &   Mass\newline Volume\newline Density\newline Proportion  &   :\newline :\newline :\newline : &   \textit{$m_{\alpha}$}\newline \textit{$v_{\alpha}$}\newline \textit{$\rho_{\alpha}$}\newline \textit{$p_{\alpha}$}\\ \hline
Cylinder                            &   Mass\newline Volume\newline Density                     &   :\newline :\newline :           &   \textit{$m_{cyl}$}\newline \textit{$v_{cyl}$}\newline \textit{$\rho_{cyl}$}\\
\hhline{|b:====:b|}
\end{xltabular}
\end{center}

\end{document}

Working fine


Having reduced the number of packages not to pollute the MWE 1.0, my first thought was that the issue comes from some incompatibility between some of those. So here is my MWE 2.0, with all the packages I use and need, and its result :

\PassOptionsToPackage{x11names}{xcolor}
\documentclass[11pt,fleqn,french]{report}

\usepackage{geometry}                               
\geometry{a4paper}

\usepackage{background}
\backgroundsetup{contents=MWE}

\usepackage[utf8]{inputenc}                     
\usepackage[OT1]{fontenc}
\usepackage{pdflscape}
\usepackage{rotating}
\usepackage{booktabs,bigstrut}
\usepackage[parfill]{parskip}                   
\usepackage{graphicx,float}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{fancyhdr} 
\usepackage{epstopdf}
\usepackage{lipsum}
\usepackage{babel,csquotes,xpatch}
\usepackage{ifthen}
\usepackage{array}
\usepackage{textcomp}
\usepackage{hyperref}
\usepackage{nomencl}
\usepackage[toc,acronym]{glossaries}
\usepackage[backend=biber,style=numeric-comp,sorting=none]{biblatex}
\usepackage{microtype}
\usepackage{caption,subfloat,subcaption}
\usepackage{wrapfig}


\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepgfmodule{plot}
\usepgfplotslibrary{fillbetween}

\usepackage{tikz}
\usetikzlibrary{calc,shapes,decorations.pathmorphing,backgrounds,plotmarks,3d,patterns}

\usepackage{makecell,hhline,longtable}
\usepackage[longtable]{multirow}

\usepackage[column=0]{cellspace}
\newcommand{\imageborder}{2pt}
\setlength\cellspacetoplimit{\imageborder}
\setlength\cellspacebottomlimit{\imageborder}

\usepackage[export]{adjustbox}
\usepackage{xltabular}
\renewcommand\tabularxcolumn[1]{m{#1}}

\newcolumntype{L}[1]{>{\raggedright\arraybackslash}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}m{#1}}


\begin{document}

\begin{center}
\begin{xltabular}{0.75\linewidth}{|c|L{40mm}L{2mm}L{15mm}|}
\hhline{|t:====:t|}
\multicolumn{1}{|c|}{\textbf{Part}} &   \multicolumn{3}{c|}{\textbf{Data}}  \endfirsthead \hline
Material \textit{$\alpha$}          &   Mass\newline Volume\newline Density\newline Proportion      &   :\newline :\newline :\newline : &   \textit{$m_{\alpha}$}\newline \textit{$v_{\alpha}$}\newline \textit{$\rho_{\alpha}$}\newline \textit{$p_{\alpha}$}\\ \hline
Cylinder                            &   Mass\newline Volume\newline Density                         &   :\newline :\newline :           &   \textit{$m_{cyl}$}\newline \textit{$v_{cyl}$}\newline \textit{$\rho_{cyl}$}\\
\hhline{|b:====:b|}
\end{xltabular}
\end{center}

\end{document}

Working finen't

As you can see, there is an obvious indentation on the first "subline" of each of the table's lines. My very first try was with a 3-column table, thus including a \multicolumn{2}{}{} for the data, and the indent was being applied to both ":" and the variables. My guess is this issue appears on the second column of the \multicolumn, but I don't get the reason why.

Any help would be very very much appreciated, please and thank you for your time and consideration.

9
  • 2
    Welcome to TeX.SX! I cannot reproduce this with your second MWE and a current TeX installation. Please add an information as to which compilation engine (PDFLaTeX/XeLaTeX/LuaLaTeX) you use and which version your TeX installation has. Maybe updating the relevant packages already can solve this problem. Jul 7, 2023 at 11:03
  • Hey @JasperHabicht, thanks for your comment ! I just edited my question and updated my whole LaTeX installation, all the packages included. I still have the same issue, the indent stands still, I just don't get it
    – Marck
    Jul 7, 2023 at 11:24
  • As I said, I cannot reproduce this with PDFLaTeX 2.6-1.40.25. But I cannot reproduce it with older TeX distros (via Overleaf) either. Did you try to compile from scratch (and compile at least two times)? Jul 7, 2023 at 13:50
  • 1
    I mean that you should delete all the auxiliary files that have been generated during the compilation process, so that you only keep these files that are really necessary for compilation (the .tex file of course, and maybe a .bib file etc.). Then compile your file at least twice. Jul 7, 2023 at 14:59
  • 1
    Your MWE does not show it, but you are probably using french as language in your document. With this, the babel package adds some space before a colon. To avoid that locally, you can add \shorthandoff{:) before the relevant part and \shorthandon{:) after it. Also see tex.stackexchange.com/q/155015/47927 for other solutions. Jul 7, 2023 at 17:43

1 Answer 1

1

A MWE that reproduces your problem would be (I simplified your code a bit):

\documentclass[11pt,french]{report}
\usepackage[utf8]{inputenc}
\usepackage[OT1]{fontenc} 

\usepackage[a4paper]{geometry}                               

\usepackage{babel}

\usepackage{xltabular}
\usepackage{hhline}

\newcolumntype{L}[1]{>{\raggedright\arraybackslash}m{#1}}

\begin{document}

\begin{center}
\begin{xltabular}{0.75\linewidth}{|c|L{40mm}@{}L{2mm}L{15mm}|}
    \hhline{|t:====:t|}
    \textbf{Part} 
        & \multicolumn{3}{c|}{\textbf{Data}} \endfirsthead \hline
    Material $\alpha$
        & Mass\newline Volume\newline Density\newline Proportion  
        & :\newline :\newline :\newline : 
        & $m_{\alpha}$\newline $v_{\alpha}$\newline $\rho_{\alpha}$\newline $p_{\alpha}$\\ \hline
    Cylinder
        & Mass\newline Volume\newline Density 
        & :\newline :\newline :
        & $m_{cyl}$\newline $v_{cyl}$\newline $\rho_{cyl}$\\
    \hhline{|b:====:b|}
\end{xltabular}
\end{center}

\end{document}

enter image description here

The reason for the space in front of the colons in the first row is the fact that the babel package adds this space before a colon if french is loaded as language. There are different ways to cope with this problem. One solution is to place \shorthandoff{:} before the relevant code \shorthandon{:} after it to temporarily deactivate this behaviour. Alternatively, you could add \NoAutoSpacing right at the beginning of the relevant cell in which you want to deactivate the default spacing mechanism:

\documentclass[11pt,french]{report}
\usepackage[utf8]{inputenc}
\usepackage[OT1]{fontenc} 

\usepackage[a4paper]{geometry}                               

\usepackage{babel}

\usepackage{xltabular}
\usepackage{hhline}

\newcolumntype{L}[1]{>{\raggedright\arraybackslash}m{#1}}

\begin{document}

\begin{center}
\begin{xltabular}{0.75\linewidth}{|c|L{40mm}@{}L{2mm}L{15mm}|}
    \hhline{|t:====:t|}
    \textbf{Part} 
        & \multicolumn{3}{c|}{\textbf{Data}} \endfirsthead \hline
    Material $\alpha$
        & Mass\newline Volume\newline Density\newline Proportion  
        & \NoAutoSpacing :\newline :\newline :\newline : 
        & $m_{\alpha}$\newline $v_{\alpha}$\newline $\rho_{\alpha}$\newline $p_{\alpha}$\\ \hline
    Cylinder
        & Mass\newline Volume\newline Density 
        & \NoAutoSpacing :\newline :\newline :
        & $m_{cyl}$\newline $v_{cyl}$\newline $\rho_{cyl}$\\
    \hhline{|b:====:b|}
\end{xltabular}
\end{center}

\end{document}

enter image description here

You must log in to answer this question.

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