描述环境中的表格对齐

描述环境中的表格对齐

为什么表格在描述环境中没有与文本对齐?我希望它具有与文本相同的左缩进和宽度。这可能吗?

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

在此处输入图片描述

答案1

ltablex包将 tabularx “转换”为 longtable。默认情况下,longtable 位于文本正文的中心。如果您希望它沿着描述的左边距对齐,请设置\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}

答案2

由于您希望您的tabularx环境忽略的description缩进,请将其替换\linewidth\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}

在此处输入图片描述

相关内容