Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am writing a chapter on Unicode. I'm using LaTeX using the fancyvrb chapter and inputenc, which lets me type most unicode characters without problem.

Problem: I want to include a character from the Supplementary Code Plane. Specifically the G Clef. Here is the code I want:

\begin{Verbatim}
>>> cleff=u"\U0001D11E"
>>> len(cleff)
2
>>> type(cleff)
<type 'unicode'>
>>> cleff[0]
u'\ud834'
>>> cleff[1]
u'\udd1e'
>>> import sys
>>> sys.stdout.write(cleff.encode('utf-8')+"\n")
𝄞
>>> 
\end{Verbatim}

By the way, this won't show up properly on your browser unless you can show these funky Unicode characters as well. (See http://programmers.stackexchange.com/questions/102205/should-utf-16-be-considered-harmful for an explanation).

My question --- is there any way to do this?

share|improve this question
1  
Which font are you using? And, which TeX engine (pdftex, xetex, luatex) are you using? –  Mico Oct 24 '11 at 3:32
add comment

1 Answer

up vote 2 down vote accepted

If you want to typeset many speical unicode characters, don't use inputenc, you should use XeLaTeX or LuaLaTeX with a unicode font.

Furthermore, your font should have this symbol. I don't have any font which contains U+1D11E. Thus I can't give you a real example.


Alternatively, you can escape to LaTeX to typeset the symbol or include a graphic. You don't have to use XeTeX or LuaTeX. And you don't have to have any fonts for the symbol — it doesn' matter.

Since I can hardly find a font for G-Cleff, this method is more practicable.

Example:

\documentclass{article}
\usepackage{fancyvrb}

\font\musixfont="musix11" at 7pt
\newcommand\cleff{{\musixfont G}} % G-Cleff symbol from MusixTeX fonts

\begin{document}

\begin{Verbatim}[commandchars=\$\{\}]
>>> cleff=u"\U0001D11E"
>>> len(cleff)
2
>>> type(cleff)
<type 'unicode'>
>>> cleff[0]
u'\ud834'
>>> cleff[1]
u'\udd1e'
>>> import sys
>>> sys.stdout.write(cleff.encode('utf-8')+"\n")
$cleff
>>> 
\end{Verbatim}

\end{document}

enter image description here

share|improve this answer
    
Thanks for the comment. How do you post the output of the LaTeX? Does the blog do that automatically, or do you need to upload that somewhere? For various reasons I do not want to use xetex. Is there any other way to do this? –  vy32 Oct 24 '11 at 16:57
    
@vy32: Upload an image. The image I posted is just a screen snapshot. –  Leo Liu Oct 25 '11 at 1:39
    
Thanks. I thought (had hoped?) that this LaTeX blog would have a way of just doing an eval or something. –  vy32 Oct 25 '11 at 17:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.