Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

text surrounded by horizontal rules?

560 views
Skip to first unread message

mjs

unread,
Mar 29, 2002, 1:05:45 AM3/29/02
to
I would like to display an arbitrary line of text with a horizontal
rule on each side, but am having difficulty achieving this effect.

An ascii example of the desired output:

------------------------- A Few Words of Text -------------------------

The dashed lines are, of course, supposed to be solid lines.

I tried this:

\begin{center}
\hrulefill A Few Words of Text{}\hrulefill
\end{center}

which almost does what I want, but the rules are positioned vertically
on the baseline, so the output looks like this:

_________________________ A Few Words of Text _________________________

I need the rule to size itself (like \hrulefill) since I will be
automatically generating the output (i.e., no absolute length, unless
these can be easily calculated).

There seems to be no way to move the \hrulefill output to the vertical
middle of the line. I tried playing with \raisebox and \rule with no
luck.

Any suggestions?

-- Mike

To reply via email, remove NOSPAM from above email address.

Wald

unread,
Mar 29, 2002, 4:04:19 AM3/29/02
to
Why don't you just lower the text instead of raising the \hrulefill's ?

\begin{center}
\hrulefill \raisebox{-.5ex}{A Few Words of Text} \hrulefill
\end{center}

Greetz,
Wald

"mjs" <mj...@NOSPAM.ptd.net> wrote in message
news:ZuTo8.1296$bg.1...@nnrp1.ptd.net...

Donald Arseneau

unread,
Mar 29, 2002, 5:27:24 AM3/29/02
to
mjs <mj...@NOSPAM.ptd.net> writes:

> \hrulefill A Few Words of Text{}\hrulefill
>

> which almost does what I want, but the rules are positioned vertically
> on the baseline,

Look at the definition of \hrulefill. Change \hrule to
\hrule height xxx depth -yyy
where xxx is, say, .3ex and yyy is 0.4pt less

Donald Arseneau as...@triumf.ca

mjs

unread,
Mar 29, 2002, 8:18:17 AM3/29/02
to
Unfortunately the inter-line spacing is not nicely maintained (the
space to the next line is too small).

-- Mike

To reply via email, remove NOSPAM from above email address.

Wald <arnout.s...@nospam.agr.kuleuven.ac.be> wrote:
: Why don't you just lower the text instead of raising the \hrulefill's ?

mjs

unread,
Mar 29, 2002, 8:24:48 AM3/29/02
to
Exposing further ignorance (newbie alert) ... where is the definition?
Do I need to recompile TeX itself or is this in a configuration file?

I have tetex 1.0.7 running on Linux.

-- Mike

To reply via email, remove NOSPAM from above email address.

Donald Arseneau <as...@triumf.ca> wrote:

Ulrike Fischer

unread,
Mar 29, 2002, 9:18:47 AM3/29/02
to
mjs <mj...@NOSPAM.ptd.net> schrieb:

> Exposing further ignorance (newbie alert) ... where is the definition?
> Do I need to recompile TeX itself or is this in a configuration file?
>

Standard latex-Definition are in latex.ltx, sometimes in one of the
class- files or in the .clo-files. \hrulefill is in latex.ltx.

Don't change latex.ltx!!! Copy the definition in your document,
surrounded by \makeatletter .. \makeatother and change it there.

Ulrike Fischer

mjs

unread,
Mar 29, 2002, 10:07:57 PM3/29/02
to
Thanks to everyone who responded. This is what I came up with:

\makeatletter
\def\hrulefill{\leavevmode\leaders\hrule height 4pt depth -3pt\hfill\kern\z@}
\makeatother

\hrulefill this is simply the middle{}\hrulefill


-- Mike

To reply via email, remove NOSPAM from above email address.


mjs <mj...@nospam.ptd.net> wrote:
: I would like to display an arbitrary line of text with a horizontal

David Kastrup

unread,
Mar 29, 2002, 10:22:21 PM3/29/02
to
mjs <mj...@nospam.ptd.net> writes:

> Thanks to everyone who responded. This is what I came up with:
>
> \makeatletter
> \def\hrulefill{\leavevmode\leaders\hrule height 4pt depth -3pt\hfill\kern\z@}
> \makeatother
>
> \hrulefill this is simply the middle{}\hrulefill

It is a very bad idea to redefine a command like that since you never
know where in the internals of TeX/LaTeX or other packages it might
also be used. It would be much saner to define a macro \crulefill
instead (for centered rule fill), or any other name that has not yet
been taken.

--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Email: David....@t-online.de

mjs

unread,
Mar 30, 2002, 11:56:50 PM3/30/02
to
Good advise I'm sure.

I am new to TeX/LaTeX, so was happy to just get the results I wanted. My
first attempt at defining a new command failed (I had thought of that,
actually), but with Donald Arseneau's assistance (I'm taking no credit
for the following code), this gives the same results:

\makeatletter
\newcommand\centrulefill{\leavevmode
\begingroup % local length assignments!
\setlength{\dimen@}{0.5ex}% or whatever positioning
\addtolength{\dimen@}{0.4pt}% or whatever thickness
\leaders\hrule height\dimen@ depth -.5ex \hfill
\endgroup
\kern\z@}

\centrulefill this is simply the middle{}\centrulefill


-- Mike

To reply via email, remove NOSPAM from above email address.


David Kastrup <David....@t-online.de> wrote:

0 new messages