Page LayoutStarred Version of the '\makebox' Command

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
kornaros
Posts: 40
Joined: Wed Nov 30, 2011 12:11 am

Starred Version of the '\makebox' Command

Post by kornaros »

When I write

Code: Select all

\makebox[1\width][l]{To ensure that white space is produced even at points in the document where line breaking takes place, one should replace \hspace by \hspace*}
the produced text-box does not break to the next lines!!! Is it possible to write a \makebox* command that breaks to more lines and respect hyphenation?

Thanks!

Charis

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

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

Starred Version of the '\makebox' Command

Post by localghost »

Code: Select all

\parbox{\textwidth}{To ensure that white space is produced even at points in the document where line breaking takes place, one should replace \hspace by \hspace*}

Thorsten
kornaros
Posts: 40
Joined: Wed Nov 30, 2011 12:11 am

Re: Starred Version of the '\makebox' Command

Post by kornaros »

Parbox is not useful because the text does not continues normally! Please have a look at the following example

To ensure that white space is produced even at points \parbox{\textwidth}{To ensure that white space is produced even at points in the document where line breaking takes place, one should replace hspace by hspace*} similar when we need horizontal...

%%% the text goes out of the page....!!
I would like a "local" makebox (i.e. into some paragraph) so that the the text outside of the box flows (runs) "normally" with the text in the box. My English is poor so I hope you to understand what thing I am talking about...

Thanks

Charis
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Starred Version of the '\makebox' Command

Post by Stefan Kottwitz »

Hi Charis,
kornaros wrote:My English is poor so I hope you to understand what thing I am talking about...
perhaps explain with code, if writing English is difficult. Most of the people here understand code. In the post above I don't see what is the "example", there's just a \parbox{...}{...} surrounded by normal post text. I don't see if this outer text should be code too.

Stefan
LaTeX.org admin
kornaros
Posts: 40
Joined: Wed Nov 30, 2011 12:11 am

Starred Version of the '\makebox' Command

Post by kornaros »

Please try the following code to see yourself the result of \parbox!

Code: Select all

\documentclass{article}
    
\begin{document}
To ensure that white space is produced even at points
\parbox{\textwidth}{To ensure that white space is produced even
at points in the document where line breaking takes place, one should replace
hspace by hspace*} and as you see this parboxed text goes outside text...!!!!
\end{document}
Last edited by Stefan Kottwitz on Mon Feb 27, 2012 11:31 am, edited 2 times in total.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Starred Version of the '\makebox' Command

Post by cgnieder »

I'm not sure I understood what you want (a Infominimal working example and/or a picture might have been helpful). I guess, though, that you want something like this?

Code: Select all

\documentclass{article}
\usepackage{wrapfig}
\usepackage{kantlipsum} % create dummy text
\begin{document}

\begin{wrapfigure}[6]{r}{5cm}\itshape
 ``Imagine a world in which every single person on the planet is given
 free access to the sum of all human knowledge. That's what we're doing''
\end{wrapfigure}
\kant[1]

\begin{wrapfigure}[7]{l}{5cm}\itshape
 ``Imagine a world in which every single person on the planet is given
 free access to the sum of all human knowledge. That's what we're doing''
\end{wrapfigure}
\kant[2]

\end{document}
wrapped_text.png
wrapped_text.png (68.49 KiB) Viewed 4586 times
Regards
site moderator & package author
kornaros
Posts: 40
Joined: Wed Nov 30, 2011 12:11 am

Starred Version of the '\makebox' Command

Post by kornaros »

Thank you all for your replies!
Your answers is not exactly what I am talking about... I try to write a version of \makebox (let us say \makebox*) so that \makebox*{some text here} respects
  1. Hyphenation rules of the document language
  2. it will respect line breaking i.e.
If there no more horizontal space left then the "some text here…" will continue to the next line! So if , for example, I write

Code: Select all

\makebox*[1.5\textwidth][s]{This is my first sentence}
\makebox*[1.5\width] {This is my second sentence}
\makebox*[1\width] {This is my third sentence}
then the result will be a normal text except that: The “This is my first sentence” will be spread 1.5\width in length and the “This is my second sentence” will be spread only 1.5\textwidth in length! and the last This is my third sentence will be a normal spread sentence. That is, the first sentence will be more spread out that the second one (at a specific amount!)

Anyway thank you very much for your replies.
Post Reply