I have an environment which left and right skips are set to same value. Inside it I have a text and a rule below that text. I want rule to have exactly same width as text above it. (Similarly to what would happen in HTML when horizontal rule is inside div of fixed width; rule should expand to the width of that div and hence be same width as text.)
The closest I have come to solution:
\documentclass[final,11pt]{book} \newenvironment{myenv}{% \par% \addtolength{\leftskip}{3em}% \addtolength{\rightskip}{3em}% \vspace{1em}% }{% \par% \addtolength{\leftskip}{-3em}% \addtolength{\rightskip}{-3em}% \vspace{1.5em}% } \begin{document} \noindent\begin{myenv} \noindent Lorem ipsum dolor sit amet, consectetur adipisicing elit. Explicabo beatae, cumque omnis pariatur. Nam, unde sunt exercitationem odit vitae suscipit dolor libero autem cum aliquam, dolores ipsam omnis nulla distinctio, voluptas quae tenetur temporibus repellat praesentium! Obcaecati veritatis, harum, voluptate sequi ducimus fugit mollitia, autem dolor facere enim, sit deleniti! \centerline{\rule{4.1in}{0.2pt}} \end{myenv} \end{document} which produces this:
As far as I can see, rule is wider than block of text on the left side and a bit narrower on the right side. How can I make this rule take 100% of the environment width (that is: taking into account skips), so that it is exactly same width as text above it? Ideally, solution would not require setting value manually, but use something like \textwidth or \linewidth (which do not produce desired result right now).




\noindent\hrulefill.\leftskipand\rightskipdirectly in latex (as otehrwise any nested environments such as lists or center etc will do the wrong thing) the environment should be defined as a list (as for example quote is) then latex sets up all the dependent lengths an\linewidthis always the width of the current text block inside the margins. Also\noindentbefore\begin{myenv}is rather weird (and just produces an anomalous empty paragraph) as the environment starts with\parmyenv. In that case, is there any side effect of using\leftskipand\rightskipinmyenvdefinition? In other words: can it affect any text outsidemyenvenvironment?