5

Why table doesn't align as a text in description environment? I want it has same left indent and width as text. Is that possible?

\documentclass[a4paper,oneside]{book}
\usepackage[paper=a4paper, left=1.5cm, right=1cm, top=1.7cm, bottom=2.5cm]{geometry}
\usepackage{ltablex}
\usepackage[utf8]{inputenc}
\parindent=0pt
\begin{document}
\textbf{Just an example}

\begin{description}
\item[\textit{Lorem Ipsum is}] \hfill \linebreak
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard.
\end{description}

\begin{description}
\item[\textit{Lorem Ipsum is}] \hfill \linebreak
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard.
\begin{tabularx}{\linewidth}{|X|X|X|} \hline
{\centering Header1} & {\centering Header2} & {\centering Header3} \\ \hline
cell 1.1 & Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard  & cell 1.3 \\ \hline
cell 1.1 & Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard  & cell 1.3 \\ \hline
\end{tabularx}
\end{description}

\begin{tabularx}{\linewidth}{|X|X|X|} \hline
{\centering Header1} & {\centering Header2} & {\centering Header3} \\ \hline
cell 1.1 & Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard  & cell 1.3 \\ \hline
cell 1.1 & Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard  & cell 1.3 \\ \hline
\end{tabularx}

\end{document}

enter image description here

2

2 Answers 2

6

The ltablex package "converts" tabularx to a longtable. And longtables are by default centered in the textbody. If you want it to align along the left margin of the description set \LTleft:

\documentclass[a4paper,oneside]{book}
\usepackage{ltablex}
\begin{document}
\begin{description}
\item[\textit{Lorem Ipsum is}] \hfill \linebreak
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard.

\begin{tabularx}{\linewidth}{|X|} \hline
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard.
\end{tabularx}%

\LTleft=\leftmargin
\begin{tabularx}{\linewidth}{|X|} \hline
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard.
\end{tabularx}%
\end{description}
\end{document}
0
6

As you want your tabularx environment to ignore description's indentation, replace \linewidth with \textwidth.

\documentclass[a4paper,oneside]{book}
\usepackage[paper=a4paper, left=1.5cm, right=1cm, top=1.7cm, bottom=2.5cm]{geometry}
\usepackage{ltablex}
\usepackage[utf8]{inputenc}
\parindent=0pt
\begin{document}
\textbf{Just an example}

\begin{description}
\item[\textit{Lorem Ipsum is}] \hfill \linebreak
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard.
\end{description}

\begin{description}
\item[\textit{Lorem Ipsum is}] \hfill \linebreak
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard.
\begin{tabularx}{\textwidth}{|X|X|X|} \hline
{\centering Header1} & {\centering Header2} & {\centering Header3} \\ \hline
cell 1.1 & Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard  & cell 1.3 \\ \hline
cell 1.1 & Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard  & cell 1.3 \\ \hline
\end{tabularx}
\end{description}

\begin{tabularx}{\linewidth}{|X|X|X|} \hline
{\centering Header1} & {\centering Header2} & {\centering Header3} \\ \hline
cell 1.1 & Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard  & cell 1.3 \\ \hline
cell 1.1 & Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard  & cell 1.3 \\ \hline
\end{tabularx}

\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 .