Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
    
here is pdf web-engineering.com.ua/table-desc.pdf –  Andrew May 29 '12 at 13:19
    
I've inserted the pdf as an image –  Ignasi May 29 '12 at 15:43
add comment

2 Answers

up vote 6 down vote accepted

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}
share|improve this answer
    
Thank you very much. It works fine –  Andrew May 29 '12 at 14:48
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.