Text Formatting\newline doesn't work inside \mbox{}

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
rogozyn
Posts: 2
Joined: Thu Jan 27, 2011 4:28 pm

\newline doesn't work inside \mbox{}

Post by rogozyn »

Can somebody tell me why I can't move to next line with command \newline or \\ ?

It works perfectly in main body, but inside \mbox or \caption I can't
force it to do what I ask.

I have even installed livetex-full under Ubuntu (ealier was installed default).I'm beginner so I have put that information just incase it is important.
The same problem is under windows miktex. At the begining I thought that something is mising.

Code:

\documentclass[a4paper,10pt]{report}
\usepackage[utf8x]{inputenc}

\begin{document}

Here moving to \\next line works


\mbox{Here it \\ doesn't}


\end{document}


I used pdflatex and latex command under console (I have got the same effect).

It's what i have got after pdflatex:
http://fatcat.ftj.agh.edu.pl/~pradera/xx.pdf

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

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

\newline doesn't work inside \mbox{}

Post by frabjous »

That's perfectly normal. \mbox-es are typeset in LR mode, not paragraph mode. Try a parbox instead.

Code: Select all

\documentclass[a4paper,10pt]{report}
\usepackage[utf8x]{inputenc}

\begin{document}

Here moving to \\next line works


\parbox[t]{3cm}{Here it \\ also does}


\end{document}
rogozyn
Posts: 2
Joined: Thu Jan 27, 2011 4:28 pm

Re: \newline doesn't work inside \mbox{}

Post by rogozyn »

Thank you. It helped.
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Re: \newline doesn't work inside \mbox{}

Post by sommerfee »

And regarding \caption: You can use \\ inside \caption if either the caption package will be used or the text of the caption will be longer than a single line.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

\newline doesn't work inside \mbox{}

Post by localghost »

rogozyn wrote:Thank you. It helped.
If so, please mark the topic accordingly as written in Section 3 of the Board Rules (to be read before posting).


Best regards and welcome to the board
Thorsten
Post Reply