General\textonehalf

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
tomgoos
Posts: 5
Joined: Tue Feb 26, 2008 1:34 pm

\textonehalf

Post by tomgoos »

Hi all,

Today I tried to put the symbol 1/2 in my latex document. I could find the one with a horizontal dash (\textonehalf) but I actually need the one with a diagonal dash (like 1/2). In unicode its this one ½, however if I try to put the unicode symbol in my latex document using

Code: Select all

\usepackage{ucs} 
\usepackage[utf8x]{inputenc}
and then use

Code: Select all

\unichar{189}
I, again.., get the one with a horizontal dash instead of the one with a diagonal dash.... aaaarghhhh :cry:

Does anyone know how to obtain the 1/2 sign with a diagonal dash in latex?

Cheers,
Tom

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

\textonehalf

Post by gmedina »

One possibility: add in the preamble

Code: Select all

\usepackage{units}
and then, to obtain your fraction:

Code: Select all

\nicefrac{1}{2}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
tomgoos
Posts: 5
Joined: Tue Feb 26, 2008 1:34 pm

Re: \textonehalf

Post by tomgoos »

Ah, nice one! It works, that solves my problem. I'm still interested in a single symbol solution though because this still would look slightly nicer. But thanks again for this one, it is a good solution.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

\textonehalf

Post by gmedina »

Then maybe the Comprehensive LaTeX Symbols List could be useful.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
tomgoos
Posts: 5
Joined: Tue Feb 26, 2008 1:34 pm

Re: \textonehalf

Post by tomgoos »

Thanks, I already checked that list. It has the half sign with a horizontal dash but not with the diagonal dash (or at least I was not able to find it although I gave it my best shot).
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

\textonehalf

Post by gmedina »

You are right. In fact, in page 64 of that document, the author suggests the use of \nicefrac to obtain that kind of fractions.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

\textonehalf

Post by localghost »

The textcomp package (Text Companion Fonts) provides exactly this command to get what you want.

Code: Select all

\textonehalf

Best regards
Thorsten¹
tomgoos
Posts: 5
Joined: Tue Feb 26, 2008 1:34 pm

Re: \textonehalf

Post by tomgoos »

Yes, I found this one, however, it gives the half sign with a horizontal dash and not the diagonal dash. Normally I would not care about the dash being horzontal or diagonal but I want to refer to exactly this symbol in a figure that I have. Therefore I would like it to be the same. Thanks for the suggestion.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

\textonehalf

Post by localghost »

tomgoos wrote:Yes, I found this one, however, it gives the half sign with a horizontal dash and not the diagonal dash. [...]
I can't confirm that. I get exactly what you you are searching for, a fraction with a diagonal line. So, please post a minimal working example (MWE) that shows the opposite.
tomgoos
Posts: 5
Joined: Tue Feb 26, 2008 1:34 pm

\textonehalf

Post by tomgoos »

Sorry for the late reaction but here an MWE

Code: Select all

\documentclass{article}
\usepackage{textcomp}

\begin{document}
\textonehalf
\end{document}
It gives me the horizontal dash
Post Reply