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.

14
  • I'll try to edit the post with simplified version to better isolate the issue. @moewe I have exactly the same versions
    – simPod
    Oct 1, 2016 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 1, 2016 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 1, 2016 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 1, 2016 at 16:29
  • 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 3, 2016 at 6:45

1 Answer 1

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.

4
  • 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 1, 2016 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. Oct 1, 2016 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 1, 2016 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. Oct 1, 2016 at 16:57

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