Text Formattingputting a word between lines

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Avogel
Posts: 2
Joined: Thu Nov 18, 2010 9:24 pm

putting a word between lines

Post by Avogel »

Hello, I'm trying to put a word like this:

------------
this is text
------------

but with the "------" being a full line.
(so basicly putting it in a box without right and left side.)

What command can I use for this?

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

putting a word between lines

Post by gmedina »

Hi,

you could use something like this:

Code: Select all

\documentclass{article} 

\begin{document} 

\noindent\hrulefill\par
\centering Some text\\[-.5\baselineskip]
\hrulefill\par

\end{document} 
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Avogel
Posts: 2
Joined: Thu Nov 18, 2010 9:24 pm

Re: putting a word between lines

Post by Avogel »

Thats seems to work, but it's not rly doing what I'm looking for.
If i use your way, it fills the whole line with a line. and i only mean it to draw a line as big as the text.
Any more ideas?
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

putting a word between lines

Post by gmedina »

Code: Select all

\documentclass{article} 

\newlength\mylen
\settowidth\mylen{Some text}
\newcommand*\myrule{\rule{\mylen}{0.4pt}}

\begin{document} 

\noindent\myrule\\
Some text\\[-.5\baselineskip]
\myrule

\end{document} 
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

putting a word between lines

Post by localghost »

Code: Select all

\documentclass{article}

\begin{document}
  \begin{tabular}{@{}c@{}}\hline
    Words between lines \\ \hline
  \end{tabular}
\end{document}

Best regards and welcome to the board
Thorsten
Post Reply