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}
7
  • 2
    the bibtex syntax is {\v S} not \v{S} Commented Sep 6, 2018 at 18:42
  • 3
    @DavidCarlisle Wait, BibTeX has a different syntax then LaTeX?!
    – Canageek
    Commented Sep 6, 2018 at 18:48
  • 11
    It's not my fault Commented Sep 6, 2018 at 18:52
  • 1
    the \v{z} and ć only work as they are not used at a place where bibtex needs to separate a single letter Commented Sep 6, 2018 at 18:56
  • @Canageek - The input syntax rules for LaTeX and BibTeX are most definitely not the same. See the earlier posting and the most-upvoted answer (shamless self-citation alert) for more information on this subject.
    – Mico
    Commented Sep 6, 2018 at 20:30

2 Answers 2

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}

7
  • 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)? Commented Sep 7, 2018 at 7: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. Commented Sep 7, 2018 at 7: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. Commented Sep 7, 2018 at 9: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" Commented Sep 7, 2018 at 9: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. Commented Sep 7, 2018 at 9:10
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

0

You must log in to answer this question.

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