I have a problem with the indentation done by the addmargin environment of the koma script and the use of tabularx table. Clearly the \textwidth
uses the original width of the text and not the smaller one of the addmargin environment.
So the desired output is that the table is left aligned with the lipsum[1]
text and right aligned both with the lipsum[1]
and lipsum[2]
text.
MWE:
\documentclass{scrbook}
\usepackage{tabularx}
\usepackage{lipsum}
\begin{document}
\lipsum[2]
\begin{addmargin}[2\parindent]{0pt}
\lipsum[1]
\begin{tabularx}{\textwidth}{p{.2\textwidth}X}
First column & A long column which doesn't respect the margin added to the left of this page but goes into the margin on the right \\
Second column & A long column which doesn't respect the margin added to the left of this page but goes into the margin on the right \\
\end{tabularx}
\end{addmargin}
\end{document}
Best Answer
The
\textwidth
doesn't change: you have to use\linewidth
when inside a list (whichaddmargin
is); moreover you have to remember\noindent
and@{}
for removing the padding on the left and right.On the other hand,
tabularx
is not needed: