3

I have a problem with LaTeX on my mac. This is my code:

\documentclass[a4paper, 12pt, norsk]{article}
\usepackage[norsk]{babel}
\usepackage[utf8]{inputenc}

\title{Syrehydrolyse av polysakkarider og bestemmelse av reduserende ender}
\author{\bf{Jenny Nesje, Maja Knudsen og Mats Jønland}}
\date{\today}

\begin{document}
\maketitle

Hei

\end{document}

When I press 'Typeset' in TeXShop, I get this:

enter image description here

Can anyone help me? I thought \usepackage[utf8]{inputenc} should help me with special characters as æ, ø and å?

  • 1
    your code works without any issue running pdflatex (via TexMaker) for me. Have you tried running LaTeX via command line? – ebosi Oct 9 '15 at 8:34
  • 1
    It works here too. Perhaps your editor didn't actually save the file with utf-8 encoding? Anyway, if you'll require to write often in utf-8, I would suggest you to switch to xelatex. – JLDiaz Oct 9 '15 at 8:36
  • It works on my machine as well. I think our best guess is that your editor didn't actually save the file in UTF-8 encoding. – moewe Oct 9 '15 at 8:43
  • 1
    BTW: \bf is not a macro like \emph{...}, it is a switch and thus needs to be used like {\bf foo}, not like \bf{foo}. But you should probably use \textbf{...} anyway. See tex.stackexchange.com/q/41681/35864, tex.stackexchange.com/q/516/35864, – moewe Oct 9 '15 at 8:47
  • How can I check if it's saved in UTF-8 encoding? (Thanks for the tip about \bf) – Jenny Nesje Oct 9 '15 at 9:12
5

You appear to be using TeXShop, for which there's a very easy solution: add

% !TEX encoding = UTF-8 Unicode

at the top of your file and save it. Now it should compile properly.

Next, open the preferences for TeXShop and go to the “Source” tab. You probably will have a window like

enter image description here

(at least in the “Encoding” box): for historical reasons, TeXShop keeps MacRoman as the default text encoding.

From the “Encoding” pull-down menu, choose “Unicode (UTF-8)”

enter image description here

Close the preferences and from now on, all files will be saved as UTF-8. Having the “magic line” makes no harm, so you can keep it for greater safety.

If you have older files where \usepackage[applemac]{inputenc} is used, be sure to add the magic line corresponding to MacRoman, which you can add from the “Macros>Encoding” menu.

Do this addition before changing the default encoding.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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