7

I've got a citation where the authors name includes Š. LaTeX gives an "! Package inputenc Error: Invalid UTF-8 byte sequence." on this, fine, I'm used to that, so I replace it with \v{S}. That just gives me a v in the output. But \v{z} works just fine.

MWE:

\documentclass[]{article}
\usepackage[utf8]{inputenc} %Allows UTF8 input. 

\begin{filecontents}{UTF8.bib}
@Article{UTF8,
    author ="Chen, Teng-Hao and Lee, Semin and Flood, Amar H. and Miljanić, Ognjen Š.",
    title  ="How to print a crystal structure model in 3D",
    journal  ="CrystEngComm",
    year  ="2014",
}
@Article{LaTeX,
    author ="Chen, Teng-Hao and Lee, Semin and Flood, Amar H. and Miljanić, Ognjen \v{S}.",
    title  ="How to print a crystal structure model in 3D",
    journal  ="CrystEngComm",
    year  ="2014",
}
@article{TeachingReview,
    author = "Gra{\v{z}}ulis, Saulius and Sarjeant, Amy Alexis  and Kantardjieff, Katherine A and et al..",
    title = "{Crystallographic education in the 21st century}",
    journal = "Journal of Applied Crystallography",
    year = "2015",
}
\end{filecontents}
\usepackage[utf8]{inputenc}
\usepackage[super,sort&compress,comma]{natbib} 
\usepackage[T1]{fontenc}
\usepackage{natmove}

\begin{document}

Oddly Miljanić, Ognjen Š. works fine in the body of the text.\cite{UTF8} 
If I encode the name in LaTeX it works in body text: Miljanić, Ognjen \v{S}.\cite{LaTeX}
But REALLY oddly Gra{\v{z}}ulis, Saulius works everywhere.\cite{TeachingReview}

\bibliography{UTF8}
\bibliographystyle{abbrvnat} %the RSC's .bst file
\end{document}
Mico
  • 506,678
Canageek
  • 17,935

2 Answers2

10

the multibyte characters fail when bibtex is trying to take "the first letter" and just takes the first byte. Also bibtex's syntax for accent commands is {\v S} not \v{S} so you can use either of these forms:

Ognjen {\relax Š} or Ognjen {\v S}

David Carlisle
  • 757,742
  • Is it really that "bibtex syntax for accent commands" is that one, or is it simply a consequence of the fact that we should put strange commands inside a group (and then \v S or \v{S} are the same from TeX perspective, so {\v{S}} would work as well)? – Nicola Gigante Sep 07 '18 at 07:25
  • @gigabytes well depends how you view it, texdoc bibtexing the bibtex manual explictly calls out this syntax for accented characters although it is true that a group around arbitrary stuff works but note you need {\relax Š} it is not enough to have {Š} so it really is the syntax {\something ..} that bibtex is looking for, not simply that a brace group protects things. – David Carlisle Sep 07 '18 at 07:48
  • Does {something with Š inside} work? I know it's only nitpicking, but in this case it means that probably the implementation is working the other way around, i.e. it looks for {singleletter} as a special case, and everything else inside braces is left as is. – Nicola Gigante Sep 07 '18 at 09:00
  • Anyway, it seems to be a common thing in LaTeX-related software to define an "official" syntax that in reality is only a subset of what is really accepted. e.g. \newcommand\command{code} vs \newcommand{\command}{code}, the former of which works perfectly because of how TeX parses arguments, but is not officially "LaTeX syntax" – Nicola Gigante Sep 07 '18 at 09:02
  • @gigabytes {something with Š inside} no or yes depending where it is, the brace group would protect the text from upper/lower case changing but if that string was being used as for example part of a string where bibtex is making an automated abbreviation and needs single letters it would take the first byte of the utf8 S and break. The syntax {\something x} is explictly special cased to be a single letter when bibtex is splitting off single letters. – David Carlisle Sep 07 '18 at 09:10
  • Whether one writes {\relax Š} or {\v S} matters greatly if alphabetical sorting of the bib entries needs to be performed. Specifically, {\v S} is equivalent to S for sorting purposes, while {\relax Š} is guaranteed to come after Z. – Mico Sep 07 '18 at 12:15
  • @Mico true (where is it supposed to come in such an east European langauge?) I probably after S I guess ... bibtex of course is pretty flaky with non ascii sorting anyway, – David Carlisle Sep 07 '18 at 12:22
8

You are missing a brace, but beside this, add braces around the \v{S}. without it bibtex reads it as a "von":

@Article{LaTeX,
    author ="Chen, Teng-Hao and Lee, Semin and Flood, Amar H. and Miljanić, Ognjen {\v{S}}.",
    title  ="How to print a crystal structure model in 3D",
    journal  ="CrystEngComm",
} 

enter image description here

Ulrike Fischer
  • 327,261