1

This question already has an answer here:

I can't seem to get Swedish hyphenation to work within the document when using the apa6 document class, though I am using the Swedish babel package.

The problem is not citation related, but concerns the actual paper content. I have not yet inserted any citations and I am having trouble already in the document preamble (see example below).

I have tried to use UTF-8 encoding, but that gives me error.

So far I have not seen anyone mentioning the same problem.

My question is simply: How can I get Swedish hyphenation to work within the document?

This is my best try of a minimal working example (edit: updated to contain a figure, that seems to be what is causing error):

\documentclass[man]{apa6}

\usepackage[swedish]{babel}
\usepackage[T1]{fontenc} \usepackage[utf8]{inputenc}

\title{Små söta röda rävar är överblivna från året}
\shorttitle{Små söta rävar}

\author{Malin Bergqvist}
\affiliation{Linköpings universitet}

\begin{document}
\maketitle

\begin{figure}[H]
\centering
\includegraphics[width=0.5\textwidth]{Old-Woman-Young-Woman.jpg}
\caption{En välkänd optisk illusion.}
\end{figure}

\end{document}

Update: The error I am getting:

./main.fff:6:
Package inputenc Error: Unicode char \u8:�lk not set up for use with LaTeX.
See the inputenc package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.6 \caption{En v�lk�nd optisk illusion.}

Your command was ignored.
Type  I <command> <return>  to replace it with another command, or  <return>  to continue without it.

The attached image shows the results of the MWE.

All help is much appreciated, I am rather new to using LaTeX. Thank you!

Example results

marked as duplicate by egreg, Andrew Swann, Adam Liter, Jesse, Claudio Fiandrino Mar 11 '14 at 15:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • The problems that are generated by your MWE would not appear to be related to hyphenation. Instead, they seem to be related to input and output encoding matters. Try adding the instructions \usepackage[T1]{fontenc} and \usepackage[utf8]{inputenc} to the preamble and see if that fixes things. (You may also need to move the instruction \begin{document} to before the \title command. – Mico Mar 11 '14 at 8:40
  • Thank you for your reply. I have tried to use both \usepackage[T1]{fontenc} and \usepackage[utf8]{inputenc}, but UTF-8 does not seem to be compatible with apa6 and gives an error. Should it normally work with the apa6 doc class? Moving \begin{document} does not seem to work either... – Malin Mar 11 '14 at 9:09
  • 1
    @Malin I just tested your document with the two lines added, and it works just fine. Would you please update your question, with more information about which errors you get – daleif Mar 11 '14 at 9:23
  • 2
    @Mico, it seems that apa6 is writing the figure to an external file and then perhaps including it at the end, it gets an .fff extension. When I run the example, my emacs tells be that the .fff file is latin1 not utf8, thus we get the problem, when the file is input later on. – daleif Mar 11 '14 at 11:33
  • 1
    @daleif - Many thanks for providing this analysis. – Mico Mar 11 '14 at 15:21
2

It is not really a problem with apa6, but rather endfloat (which is loaded by apa6), as this example also crashes:

\documentclass[a4paper]{article}

\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc}
\usepackage[swedish]{babel}

\usepackage{endfloat}

\begin{document}

sadfsadf

\begin{figure}
\centering
\rule{5cm}{5cm}
\caption{En välkänd optisk illusion.}
\end{figure}

\end{document}

Update, Egreg actually have already given the answer in https://tex.stackexchange.com/a/144425/3929

So simply add this to your preamble

\makeatletter
\renewcommand\efloat@iwrite[1]{%
   \immediate\expandafter\protected@write\csname efloat@post#1\endcsname{}}
\makeatother

and it compiles just fine

  • Works like a charm, thanks for linking and clarifying! – Malin Mar 11 '14 at 15:19

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