Text FormattingPrevent Separation of Number and Unit Symbol

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
annmucc
Posts: 11
Joined: Mon May 16, 2011 7:33 pm

Prevent Separation of Number and Unit Symbol

Post by annmucc »

I am sure this has probably come up before, but I cannot find it - I am guessing I might not be using the correct search terms?

Anyways, I have the term '4 \textcelsius' in my source file to get the term 4 °C. However, LaTeX insists on splitting 4 and °C on two separate lines. Is there any way of forcing it to put them together? I only seem to have this problem once as yet, so a solution that will work for one instances is more than perfect!

Thanks
Ann
Last edited by annmucc on Tue Aug 23, 2011 11:42 am, 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.

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

Prevent Separation of Number and Unit Symbol

Post by frabjous »

Use a non-breaking space, ~:

Code: Select all

4~\textcelsius
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Prevent Separation of Number and Unit Symbol

Post by localghost »

For physical quantities like this use the excellent siunitx package. The line break problem then should vanish.

Code: Select all

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{siunitx}

\begin{document}
  \SI{4}{\celsius}
\end{document}
For details refer to the package manual.


Thorsten
annmucc
Posts: 11
Joined: Mon May 16, 2011 7:33 pm

Re: Prevent Separation of Number and Unit Symbol

Post by annmucc »

Thanks for your help! This has solved my problem brilliantly.

Ann
Post Reply