8

I need to insert a ⚓ into my latex document. (More info about the symbol can be found here) I have tried to use some other answers here but I have not been successful, including the question Entering Unicode characters in LaTeX, but I couldn't get anything to work. I installed texlive-xetex (Should say I am using ubuntu 10.04) but that didn't like the custom document class I am using.

This is XeTeX, Version 3.1415926-2.2-0.9995.2 (TeX Live 2009/Debian)
entering extended mode
(./design.tex
! Undefined control sequence.
l.1 \documentclass
              {project}

I also tried

\usepackage[utf8]{inputenc}

and

\usepackage[utf8x]{inputenc}

but they just bombed out without an error (however they were ok for the The vorticity $ω$ is defined as $ω = ∇ × u$. text.

So anything else I can try?


Edit: Ok so using the right command helped... (I'm relativly new to latex and never heard of xetex before!) Martigan: I don't know what a MWE is... :(

So I have commented out inputenc and it runs / compiles / what ever the proper word is when I run xelatex design.tex but the ⚓ doesn't show up.

I have also just discovered that with \usepackage[utf8x]{inputenc} and using PDFLaTeX, although kile says pdflatex finished with exit code 1 , it does generate a pdf, but instead of the ⚓ it shows [U+2693]. So maybe a font issue???

Finally: I downloaded the font PLK suggested, and after extracting and renaming to unifont I can get xelatex design.tex to find the font, but it says

! Text line contains an invalid character.
l.1 ^^@
   ^^A^^@^^@^^@
! Text line contains an invalid character.
l.1 ^^@^^A
      ^^@^^@^^@
! Text line contains an invalid character.
l.1 ^^@^^A^^@
         ^^@^^@
! Text line contains an invalid character.
l.1 ^^@^^A^^@^^@
            ^^@
! Text line contains an invalid character.
l.1 ^^@^^A^^@^^@^^@

! Unable to read an entire line---bufsize=200000.

I have this in my 'preamble' (very possibly I am doing this wrong...)

\usepackage{fontspec}
\fontspec{unifont.ttf}

I tried to read the documentation on CTAN but found it a bit hard to understand...

Here is (an extract) of my doc at the moment (forgot to past the \end{document} )

Thanks for the suggestions so far.

5
  • Can you add a MWE so that we can help you? Your post is not specific enough and does not give insight on the context where it went wrong. Give us a simple example of a failed experiment (that, to your knowledge, should have worked). We will try to focus on that first and find a way.
    – Martigan
    Dec 7, 2011 at 14:25
  • 3
    The error is obviosly caused by running xetex instead of xelatex; but something other is needed, for example loading fontspec. However it's definitely wrong using inputenc with XeLaTeX.
    – egreg
    Dec 7, 2011 at 14:28
  • Even with inputenc only a subset of unicode is understood (from what I understand). So it might be that the symbol isn't understood. And even if it is, how many fonts will have that symbol? You might be better off inserting it as a little picture?
    – Seamus
    Dec 7, 2011 at 14:31
  • I have edited to try an respond to comments. Dec 7, 2011 at 15:49
  • An explanation of minimal working example (MWE) is given at the linked page.
    – Stephen
    Dec 7, 2011 at 18:54

2 Answers 2

9

You should separate input and output. If you want to print a symbol you at first need a font which contains it. If you want to use normal latex (it will work with xelatex too) you can e.g. use the dingbat font to get an anchor. If you want to use the symbol in the input you must declare it (I'm not sure if the ⚓ copy& paste correctly):

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\DeclareUnicodeCharacter{2693}{\anchor}
\usepackage{dingbat}
\begin{document}
\anchor ⚓ 
\end{document}

With xetex you can use e.g. dejavu sans (if you get the wrong glyph:make sure that you have only version of dejavu sans). Here too you can use commands/other notation if you don't want to use the symbol in the input:

\documentclass[12pt]{article}
\usepackage{fontspec}
\begin{document}
{\fontspec{DejaVu Sans Condensed} ^^^^2693 \char"2693 ⚓}
\end{document}
3
  • 2
    And you don't need to hunt for the code of ⚓: \usepackage{newunicodechar} will allow to say \newunicodechar{⚓}{\anchor} instead of using \DeclareUnicodeCharacter in the pdflatex version.
    – egreg
    Dec 7, 2011 at 15:34
  • YAY! that works, thanks! Bit big though maybe... Dec 7, 2011 at 15:50
  • Nothing a bit of \tiny couldn't sort out! Thanks again! Dec 7, 2011 at 15:55
6

As others mentioned, you need to run "xelatex" and not "xetex" otherwise nothing will work (xelatex has all the macros you need like \documentclass). Secondly, inputenc is only for PDFTeX and can't be used with XeTeX - you need fontspec instead. Thirdly, try the GNU "unifont" font - it's the only free font I know which has a huge amount (30k+) of Unicode characters in it. It certainly has that character. Available in TTF format so fontspec can probably load it.

http://www.lgm.cl/trabajos/unifont/index.en.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .