4

Here 's my problem: I would like to reproduce the following image in Latex in order to automate the generation of my documents: Table sample

(It's french with meaningless data haha)

For now I managed to get the layout, however I didn't manage to get the vertical line thick enough like in the previous picture. The verticale line should have the height of just 1 line even if there are multiple lines in the cell.

Here's the code:

\documentclass{report}
\usepackage{tabularx}
\usepackage{xcolor}
\begin{document}
    \begin{tabularx}{\textwidth}{l c X}
        Description & \textcolor{blue}{$|$} & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi at mi non nunc interdum molestie. \\
        & & multilignes\\
        Validation & $|$ & Ceci est un texte \\
        & & multilignes\\
    \end{tabularx}
\end{document}

How should I do it ?

Thank you !

1
  • Helloc, you can try replacing your $|$ with \bluevrule defined as \newcommand{\bluevrule}[0]{\color{blue}{\rule[-0.5ex]{1mm}{3ex}}}
    – BambOo
    Oct 4 '19 at 8:53
4

I propose this variant, with a slightly simpler code, and a completely different solution, vased on a customised description environment:

\documentclass{report}
\usepackage{tabularx}
\usepackage[svgnames, x11names]{xcolor}

\usepackage{eqparbox}
\usepackage{enumitem}
\newenvironment{mydescription}[1][descr]{%
\renewcommand*{\descriptionlabel}[1]{\eqmakebox[{#1}][l]{##1}\hskip1.25em\textcolor{NavyBlue!60}{\rule[-0.8ex]{1pt}{2.5ex}}}%
\description[labelsep=1.25em, leftmargin= \dimexpr\eqboxwidth{#1}+1em+\labelsep + \fontdimen 2\font]}%
{\enddescription}

\begin{document}

 \noindent \begin{tabularx}{\textwidth}{@{}l@{\hskip1.25em\textcolor{NavyBlue!60}{\rule[-0.8ex]{1pt}{2.5ex}}\hskip1.25em}X}
        Description & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi at mi non nunc interdum molestie. \newline multilignes\\
        Validation & Ceci est un texte \newline multilignes\\
    \end{tabularx}
\bigskip

    \begin{mydescription}
        \item[Description] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi at mi non nunc interdum molestie. \newline multilignes\\
       \item[Validation] Ceci est un texte \newline multilignes\\
    \end{mydescription}

    \begin{mydescription}[descra]
        \item[Long description] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi at mi non nunc interdum molestie. \newline multilignes\\
       \item[Validation] Ceci est un texte \newline multilignes\\
    \end{mydescription}

\end{document} 

enter image description here

4

Here is a solution based on the multirowpackage:

\documentclass{report}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{xcolor}

\newcommand{\customrulesep}{\vrule width 2pt}
\newcommand{\rulesepOverOneRow}{\multirow{1}{*}{\customrulesep}}
\newcommand{\coloredRulesepOverOneRow}{\multirow{1}{*}{\color{blue}\customrulesep}}

\begin{document}
    \begin{tabularx}{\textwidth}{l c X}
        Description & \coloredRulesepOverOneRow & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi at mi non nunc interdum molestie. \\
        & & multilignes\\
        Validation & \rulesepOverOneRow & Ceci est un texte \\
        & & multilignes\\
    \end{tabularx}
\end{document}

You can adapt the thickness by changing width 2pt to any dimension you like.

Result

enter image description here

Enjoy!

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.