GeneralDetermine size of words

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
jphv
Posts: 5
Joined: Wed Aug 12, 2009 8:22 pm

Determine size of words

Post by jphv »

Hello, I want to set a background color in a line, searching I found \colorbox.

Code: Select all

\colorbox{i6blue}{Get new frame}
paints a boundigbox.

So, I tried:

Code: Select all

\colorbox{i6blue}{Get new frame\hspace{\textwidth}}
but of course I need something else... How determine the size of "Get new frame"?

With the size I could write:

Code: Select all

\colorbox{i6blue}{Get new frame\hspace{\textwidth-\GetTheWidthOf{Get new frame}}}
It's a primitive and not flexible aproach, but I'm newbie (in Latex/English).


Thanks in advance,
JP
Last edited by jphv on Mon Nov 09, 2009 5:21 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.

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

Determine size of words

Post by gmedina »

Hi,

you can use the \settowidth command to measure a given text:

Code: Select all

\documentclass{article}

\newlength\mylen{}

\begin{document}

\settowidth\mylen{text}
\the\mylen

\settowidth\mylen{text text text}
\the\mylen

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
jphv
Posts: 5
Joined: Wed Aug 12, 2009 8:22 pm

Determine size of words

Post by jphv »

Thank you very much gmedina for you reply and example!!!

Now I have a beauty title :D
Post Reply