0

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)

cfr
  • 198,882
MCMastery
  • 240
  • Please provide a complete, compilable example. – cfr May 04 '16 at 02:39
  • @cfr added example – MCMastery May 04 '16 at 02:42
  • You don't need a \documentclass to compile it? Or a document environment? Amazing. I do. – cfr May 04 '16 at 02:43
  • @cfr thats implied – MCMastery May 04 '16 at 02:45
  • No. A minimal working example (MWE) is complete. It should be such that it can be copy-paste-compiled either successfully or to reproduce the error. If people have to add stuff which you merely 'implied', it is not complete. And it is also ambiguous. The class you use frequently matters. Lots. – cfr May 04 '16 at 02:47
  • I've completed your example by way of illustration. Hope this helps you to provide one next time you need to ask a question. Please read this thread for a complete explanation of what's required. – cfr May 04 '16 at 02:50
  • 6
    \linewidth works in this case. Which brings up the question, http://tex.stackexchange.com/questions/16942/difference-between-textwidth-linewidth-and-hsize?s=1|0.9464 – John Kormylo May 04 '16 at 03:32

1 Answers1

1
\documentclass{article}
\usepackage{kantlipsum}
\begin{document}
\kant[1]
\begin{itemize}
  \item first \hrulefill
  \item second
\end{itemize}
\end{document}

minimal output

cfr
  • 198,882