0

This question already has an answer here:

I need a horizontal line to span across the page, up to the right margin (where the text would end). This works:

\rule{\hsize}{0.4pt}

But, when inside a list, the line goes over the margin because it is indented, and \hsize of course doesn't check for indentation.

How can I make the line's length account for the list's indentation?

Example:

\documentclass{article}
\begin{document}
\section{Some section}

\begin{enumerate}
    \item Some text \\ \rule{\hsize}{0.4pt}
\end{enumerate}
\end{document}

Output: output

As you can see, the line goes over the right margin. (compare to left and top margins)

marked as duplicate by Werner, Stefan Pinnow, Maarten Dhondt, Romain Picot, user13907 May 4 '16 at 7:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Please provide a complete, compilable example. – cfr May 4 '16 at 2:39
  • @cfr added example – MCMastery May 4 '16 at 2:42
  • You don't need a \documentclass to compile it? Or a document environment? Amazing. I do. – cfr May 4 '16 at 2:43
  • @cfr thats implied – MCMastery May 4 '16 at 2:45
  • 6
    \linewidth works in this case. Which brings up the question, tex.stackexchange.com/questions/16942/… – John Kormylo May 4 '16 at 3:32
1
\documentclass{article}
\usepackage{kantlipsum}
\begin{document}
\kant[1]
\begin{itemize}
  \item first \hrulefill
  \item second
\end{itemize}
\end{document}

minimal output

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