GeneralHorizontal Line with adapted Width

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
[v]
Posts: 2
Joined: Fri Sep 16, 2011 6:43 pm

Horizontal Line with adapted Width

Post by [v] »

Hello!

I'd like to know if it's possible to insert a horizontal line whose width is the same as the page content's width.

Example:

Code: Select all

\documentclass[]{article}
\usepackage[brazil]{babel}
\usepackage[latin1]{inputenc}
\usepackage{amsmath,amscd,amsthm}
\pagestyle{empty}
\begin{document}
\center
anything

\[x=a_1+a_2+a_3+a_4+a_5+a_6+a_7+a_8+a_9+a_{10}+a_{11}\]

Text..

\noindent\hrulefill %to be changed

Text..

\newpage

\[x=\sum_{p=1}^{11}a_p\]

text text text text text 

\noindent\hrulefill %to be changed

text
\end{document}
By using \noindent\hrulefill, the line's width is the same as the page's width (except margins).

Which LaTeX commands should I use to get this? (I used an image editor :D)
Page 1.
Page 1.
f0SV6[1].png (4.86 KiB) Viewed 4725 times
Page 2.
Page 2.
z9hvr[1].png (3.03 KiB) Viewed 4725 times
That is, the line's width is the width of the widest text/math line.

Is it possible?

Thank you!
Last edited by [v] on Sat Sep 17, 2011 11:14 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Horizontal Line with adapted Width

Post by localghost »

Put the concerned content in to a minipage environment of a certain width. Or try the varwidth package which will adapt this width to the content.


Best regards and welcome to the board
Thorsten
[v]
Posts: 2
Joined: Fri Sep 16, 2011 6:43 pm

Horizontal Line with adapted Width

Post by [v] »

Thank you very much! ;)

Now it's perfect.

Code: Select all

\documentclass[]{article}
\usepackage[brazil]{babel}
\usepackage[latin1]{inputenc}
\usepackage{amsmath,amscd,amsthm}
\usepackage{varwidth}
\pagestyle{empty}
\begin{document}
\center
\begin{varwidth}{1\textwidth}
\center
anything

\[x=a_1+a_2+a_3+a_4+a_5+a_6+a_7+a_8+a_9+a_{10}+a_{11}\]

Text..

\noindent\hrulefill

Text..
\end{varwidth}
\newpage
\begin{varwidth}{1\textwidth}
\[x=\sum_{p=1}^{11}a_p\]

text text text text text 

\noindent\hrulefill

text
\end{varwidth}
\end{document}
Post Reply