3

I'm trying to get APA working with special characters. I got kind of far with it but it gives me Undefined control sequence on rendering citations.

My minimal source is:

\documentclass[british]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{csquotes}

\usepackage[czech,british]{babel}

\usepackage[backend=biber,date=short,maxcitenames=2,style=apa]{biblatex}
\addbibresource{sample.bib}
\DeclareLanguageMapping{british}{british-apa}


\begin{document}
  \cite{test}
  \nocite{*}
  \printbibliography
\end{document}

My sample.bib now looks like. It's encoded with UTF8 for sure

@book{test,
    Author = {šýř čžá and íéě č},
    Title = {šýř},
}

The error is Undefined control sequence \datecircaprint \mkbibdateapalongextra. The encoding is not the issue here I believe.

simPod
  • 133
  • I'll try to edit the post with simplified version to better isolate the issue. @moewe I have exactly the same versions – simPod Oct 01 '16 at 16:16
  • I've tided the comments: the new issue is rather different from the original one. The edited issue is I think an out-and-out bug in apa.bbx. I'll ask the author to take a look! – Joseph Wright Oct 01 '16 at 16:24
  • You're right, there's some thing else :/ Shoudl I edit this when I isolate it better or delete and create new one? – simPod Oct 01 '16 at 16:28
  • I think we are OK here 'zooming in' on the issue: the one 'answer of sorts' to-date may stay or go, depending on what it's author thinks. – Joseph Wright Oct 01 '16 at 16:29
  • If Czech is the main language you need something like \DeclareLanguageMapping{czech}{czech-apa}, but there is no such thing as czech-apa.lbx. So you can't really use biblatex-apa in Czech right now without providing your own .lbx file. I'll check if there is a duplicate or write an answer later. – moewe Oct 01 '16 at 16:40
  • Thank you for that. Have you tried it? It doesn't work for me. I have created and edited that file in the correct location but it still can't find czech-apa.lbx. Anyway, it's not the problem I have, the problem now is that Undefined control sequence. Or does it compile well for you? – simPod Oct 01 '16 at 16:51
  • No, no, no. You have to create your own czech-apa.lbx. Just take english-apa.lbx as basis and translate the stuff. The .lbx file contains the definition of the missing control sequence \mkbibdateapalongextra (amongst others). – moewe Oct 01 '16 at 16:59
  • I did that exactly :) http://pastebin.com/1aEKbijU Created czech-apa.lbx from french-apa.lbx – simPod Oct 01 '16 at 17:05
  • And you also added \DeclareLanguageMapping{czech}{czech-apa}? You need to move the .lbx file to a place where TeX can find it. Check the .log file if the .lbx is found. – moewe Oct 01 '16 at 17:09
  • I wrote in the comment above that in the log it says it can't find czech-apa. Which is very weird because if I change it for example to french-apa, it works. And they are in the same folder lol. http://i.imgur.com/TfPnebp.png – simPod Oct 01 '16 at 17:15
  • Aha. If you put it into the directory of your TeX system you need to tell TeX about it. On Tex live run texhash (maybe as su?): http://tex.stackexchange.com/q/21726/35864. With MikTeX you need to refresh the FNDB. The file will always be found if it is in the current working directory. – moewe Oct 01 '16 at 17:21
  • That helped! Even with the another error I asked in a question, it disappeared. Thanks man – simPod Oct 01 '16 at 17:25
  • 1
    I have decided to close your answer as a duplicate since your edited question is quite evidently about that issue and was solved with the answer there. – moewe Oct 03 '16 at 06:45

1 Answers1

1

The writing of fddd.bib by LaTeX's environment filecontents gets broken after \usepackage[utf8]{inputenc}. Workarounds:

  • Move it before:

    \begin{filecontents}{fddd.bib}
    @book{test,
        Author = {ě+íéíáý řščžčřý},
        Title = {ščřž},
    }
    \end{filecontents}
    
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    
  • Or use package filecontents, but caution, it always overwrites the files to be generated:

    \usepackage{filecontents}% or \RequirePackage{filecontents} before `\documentclass`
    \begin{filecontents}{fddd.bib}
    @book{test,
        Author = {ě+íéíáý řščžčřý},
        Title = {ščřž},
    }
    \end{filecontents}
    

LaTeX's filecontents only uses verbatim mode via \dospecials. Special characters like backslash, hash, ... are written verbatim, but the 8-bit characters are not touched. In the example of the question, they are active by \usepackage[utf8]{inputenc} and after \usepackage[T1]{fontenc}, they are written as characters with encoding T1.

Package filecontents, however, also sanitizes the 8-bit characters. Thus the entries in UTF-8 are not changed, when written to the .bib file.

One issue remains that I get an undefined error because of \mkbibdateapalongextra, but I have not checked, that I am using the latest versions.

Heiko Oberdiek
  • 271,626
  • Normally Biber is absolutely fine with comments at the beginning of .bib files. In the MWE it is rather the problem that the UTF-8 bit is not written raw to the file (as can be seen when opening the .bib file). If I load the filecontents package, everything is fine even though we still get a comment in the .bib file - alternative stuff also works if the filecontents environment is moved to the top of the file. It could be that that is not the heart of the issue - I presume the OP initially noticed the issue in a 'productive' environment where I wouldn't assume use of filecontents. – moewe Oct 01 '16 at 15:41
  • @moewe I got it fixed in a test file right before Windows 10 decides it likes a black screen much more :-((((. Of course, the test file was gone and I had assumed the wrong reason. The real was not the star form, see updated answer. – Heiko Oberdiek Oct 01 '16 at 15:58
  • thank you for your answer. However, the issue persisted. I have simplified and edited my question, now I have the same error with \ mkbibdateapalongextra. I believe the wrongly encoded characters warning comes after this one – simPod Oct 01 '16 at 16:20
  • @simPod There are two issues. The encoding issue is answered. The undefined control sequence is open, as I have written in the last sentence. It seems to be fixed in newer versions. – Heiko Oberdiek Oct 01 '16 at 16:57