Text Formattingspace before :

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
nicr
Posts: 16
Joined: Mon Apr 28, 2008 1:30 pm

space before :

Post by nicr »

Hello every body,

When I write
HF:HNO$_3$:H$_2$O
15:1:2,5
I get
HF :HNO3 :H20
15 :1 :2,5
The problem is the space before :. Please, would someone know why I get a space before each : that I wrote? :-)

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

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: space before :

Post by Johannes_B »

Where is the minimal working example?
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
nicr
Posts: 16
Joined: Mon Apr 28, 2008 1:30 pm

space before :

Post by nicr »

Thank you Johannes_B,
I found that I have

Code: Select all

\usepackage{caption}
\DeclareCaptionLabelSeparator{colonfr}{~: }
This should be the reason.
Thank you again :-)
Last edited by cgnieder on Thu Nov 19, 2015 5:34 pm, edited 1 time in total.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

space before :

Post by Johannes_B »

You might want to check out package chemformula which makes typing chemical formulas much easier.

Code: Select all

\documentclass{article}
\usepackage[french]{babel}
\usepackage{chemformula}
\begin{document}
\ch{HF} and \ch{HNO3} and \ch{H2O}

HF:HNO$_3$:H$_2$O

{\sffamily \ch{HF} and \ch{HNO3} and \ch{H2O}

\NoAutoSpacing
HF:HNO$_3$:H$_2$O}
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

space before :

Post by cgnieder »

nicr wrote:When I write
HF:HNO$_3$:H$_2$O
15:1:2,5
I get
HF :HNO3 :H20
15 :1 :2,5
Let me guess: you're using babel with French?

Code: Select all

\documentclass{article}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\begin{document}
HF:HNO$_3$:H$_2$O
15:1:2,5
\end{document}
french1.png
french1.png (3.03 KiB) Viewed 4750 times
The solution: use proper markup and mathmode:

Code: Select all

\documentclass{article}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage{chemformula}
\begin{document}
$\ch{HF}:\ch{HNO3}:\ch{H2O}$
$15:1:2{,}5$
\end{document}
french2.png
french2.png (2.96 KiB) Viewed 4750 times
Regards
site moderator & package author
Post Reply