1

Below you see a screenshot of the below messy code. I am sorry I couldn't minimise it more. Otherwise I fear I wouldn't be able to back port it to my actual document.

The many A's overflow the minipage. Don't worry about it. It would be nice though if I would get warned when that happens.

Question

When you look at DDD and BBB and the horizontal line, they are clearly not vertically aligned. How can I get them aligned?

enter image description here

\documentclass[a4paper]{article}
\pdfpagewidth=\paperwidth
\pdfpageheight=\paperheight
\usepackage{thumbpdf}
%
\usepackage{fixltx2e}
\usepackage{a4}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%
\usepackage{itemsep}

\usepackage[margin=3cm]{geometry}

\setlength{\textwidth}{160mm}
\setlength{\oddsidemargin}{0mm}

\newcommand{\ligne}[1]{\rule[0.5ex]{\textwidth}{#1}\\}
\newcommand{\interRubrique}{\bigskip\bigskip}
\newcommand{\styleRub}[1]{\noindent\textbf{\large #1}\par}
\newcommand{\indentStd}{\noindent\hspace{\lenA}}

\newenvironment{rubrique}[2][\linewidth]%
{\styleRub{#2}%
\setlength{\lenB}{#1}%
\setlength{\lenC}{\linewidth}%
\addtolength{\lenC}{-\lenA}%
\addtolength{\lenC}{-\lenB}%
\addtolength{\lenC}{-\parindent}%
\addtolength{\lenC}{-9pt}
\indentStd\begin{tabular}[t]{p{\lenB}p{8cm}p{\lenC}}}
{\end{tabular}}

\newcommand{\lieu}[1]{{#1}\ }
\newcommand{\activite}[1]{\textbf{#1}\ }
\newcommand{\comment}[1]{\textsl{#1}\ }

\pagestyle{empty}

\begin{document}

\noitemsep

\newlength{\lenA}
\setlength{\lenA}{0.cm}
\newlength{\lenB}
\newlength{\lenC}

\begin{minipage}{\linewidth}
\hspace{-3cm}
\begin{minipage}{7cm}
\begin{center}
    AAAAAAAAAAAAAAAAA\\%
\vspace{10mm}
\end{center}
\end{minipage}
\hfill
\begin{minipage}{5cm}
CCC
\end{minipage}

\end{minipage}

\bigskip
\bigskip

\begin{rubrique}[2cm]{DDD}
\ligne{0.1mm}
BBB & x & x
\end{rubrique}

\end{document}
1
  • 1
    Best thing would be to start with a blank document, just adding what you really need and know why you need it.
    – Johannes_B
    Commented Apr 20, 2020 at 22:01

1 Answer 1

3

Adding a @{} at the beginning of tabular column specification should get rid of that unwanted left indent before the first column. Check the answer to the question here for more details.

\indentStd\begin{tabular}[t]{@{}p{\lenB}p{8cm}p{\lenC}}}

Following is your complete code that would make DDD align with BBB: (NOTE: I have commented out \usepackage{itemsep}, and invocation \noitemsep as I do not have that package installed; don't forget to uncomment those two lines after you paste this code back.)


\documentclass[a4paper]{article}
\pdfpagewidth=\paperwidth
\pdfpageheight=\paperheight
\usepackage{thumbpdf}
%
\usepackage{fixltx2e}
\usepackage{a4}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%
%\usepackage{itemsep}

\usepackage[margin=3cm]{geometry}

\setlength{\textwidth}{160mm}
\setlength{\oddsidemargin}{0mm}

\newcommand{\ligne}[1]{\rule[0.5ex]{\textwidth}{#1}\\}
\newcommand{\interRubrique}{\bigskip\bigskip}
\newcommand{\styleRub}[1]{\noindent\textbf{\large #1}\par}
\newcommand{\indentStd}{\noindent\hspace{\lenA}}

\newenvironment{rubrique}[2][\linewidth]%
{\styleRub{#2}%
\setlength{\lenB}{#1}%
\setlength{\lenC}{\linewidth}%
\addtolength{\lenC}{-\lenA}%
\addtolength{\lenC}{-\lenB}%
\addtolength{\lenC}{-\parindent}%
\addtolength{\lenC}{-9pt}
\indentStd\begin{tabular}[t]{@{}p{\lenB}p{8cm}p{\lenC}}}
{\end{tabular}}

\newcommand{\lieu}[1]{{#1}\ }
\newcommand{\activite}[1]{\textbf{#1}\ }
\newcommand{\comment}[1]{\textsl{#1}\ }

\pagestyle{empty}

\begin{document}

%\noitemsep

\newlength{\lenA}
\setlength{\lenA}{0.cm}
\newlength{\lenB}
\newlength{\lenC}

\begin{minipage}{\linewidth}
\hspace{-3cm}
\begin{minipage}{7cm}
\begin{center}
    AAAAAAAAAAAAAAAAA\\%
\vspace{10mm}
\end{center}
\end{minipage}
\hfill
\begin{minipage}{5cm}
CCC
\end{minipage}

\end{minipage}

\bigskip
\bigskip

\begin{rubrique}[2cm]{DDD}
\ligne{0.1mm}
BBB & x & x
\end{rubrique}

\end{document}

Screenshot:

DDD_meets_BBB

You must log in to answer this question.

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