1

I was creating a MWEB to ask for help changing some things in the bibliography but it is not compiling. The special characters are breaking it.

It works fine on my project, but it's a template I'm using and my LaTeX knowledge is the opposite of big. I'm missing something here.

\documentclass{article}
\usepackage[portuguese]{babel}
\usepackage{csquotes}
\usepackage[backend=biber,style=authoryear,dashed=false,backref=true]{biblatex}
\renewcommand\nameyeardelim{\addcomma\addspace}
\DefineBibliographyStrings{portuguese}{%
  url={Disponível em},
}
\DeclareFieldFormat{url}{\bibstring{url}\addcolon\space\url{#1}}
\DeclareFieldFormat{urldate}{\mkbibbrackets{#1}}

\addbibresource{\jobname.bib}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@online{WHO1,
    author = {World{\ }Health{\ }Organization},
    shortauthor = {WHO},
    title = {The Ottawa Charter for Health Promotion},
    year = {1986},
    url = {http://www.who.int/healthpromotion/conferences/previous/ottawa/en/},
    urldate = {2015-03-31},
}

@online{Google,
    author = {Google{\ }Maps},
    note = {Serviço online},
    year = {2015},
    url = {https://maps.google.com/},
    urldate = {2015-04-01},
}

@thesis{Nunes,
    author = {Nelson Filipe Nunes},
    title = {Planeador colaborativo de deslocações de bicicleta em meio urbano},
    year = {2013},
    institution = {Instituto Superior, Universidade de Lisboa},
    location = {Lisboa, Portugal},
    note = {Dissertação para obtenção do Grau de Mestre em Engenharia Informática e de Computadores},
    pages = {10-20},
}
\end{filecontents}

\begin{document}

\parencite{WHO1}
...
\parencite[6-7]{Nunes}
...
\autocite{Google}

\printbibliography

\end{document}

What is wrong/missing?

JCML
  • 167
  • You need to tell TeX the encoding, either with inputenc, or using a Unicode engine. You also need to make sure that the document is properly encoded. If I save your document UTF-8-encoded and add a \usepackage[utf8]{inputenc} everything works fine. (You might have to trash auxiliary files for this to take effect.) If what you want to demonstrate in the MWE has nothing to do with diacritics you might want to consider writing ASCII-only files; you don't even have to ship your own .bib file you can use biblatex-examples.bib. – moewe Mar 29 '16 at 05:49
  • Note that you don't want to write author = {World{\ }Health{\ }Organization},, but author = {{World Health Organization}},. See Using a 'corporate author' in the “author” field of a bibliographic entry (spelling out the name in full). – moewe Mar 29 '16 at 05:53
  • Thanks! I had indeed missed copy and pasting the \usepackage[utf8]{inputenc} from the packages in my template. I see, I was using the {\ } trick because it was the only solution I had found here, I guess I missed that link. – JCML Mar 29 '16 at 12:52

1 Answers1

2

In your MWE above you are using non-ASCII characters, so you will have to tell TeX about the encoding of your file.

You can save your file in UTF-8 encoding and use one of the Unicode engines (XeLaTeX, LuaLaTeX) or you load the inputenc package (do not use inputenc with the Unicode engines!) and give the correct file encoding in the optional argument (nowadays that is probably utf8).

\usepackage[utf8]{inputenc}

If you plan to write an MWE and the issue you want to discuss does not depend on your using non-ASCII characters you might want to avoid the issue entirely by using only plain ASCII. If you need a .bib file you can use biblatex's biblatex-example.bib which contains many sample entries and is available on all systems where biblatex is installed properly.

moewe
  • 175,683