I am trying to include a bibliography (with biblatex
) in a CV (with moderncv
). However, when I include a \textemdash{}
in a field of a bibliography entry, it renders as a space instead of an em dash. This behavior doesn't happen when I switch to \documentclass{article}
, nor does it happen with \textemdash{}
outside of a bibliography entry, nor does it happen with ---
instead of \textemdash{}
. Following is an MWE.
main.tex
:
\documentclass[11pt,colorlinks,linkcolor=true]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{blue}
\usepackage[backend=biber,
sorting=ydnt]{biblatex}
\firstname{John}
\familyname{Doe}
\addbibresource{mybib.bib}
\begin{document}
\makecvtitle
\nocite{*}
The following should render as ``Hello \textemdash{} World!'':
\printbibliography
\end{document}
mybib.bib
:
@misc{helloworld,
title = {Hello \textemdash{} World!},
author = {Doe, John},
date = {2021-08},
}
Best Answer
Biber recodes the
\textemdash
in your title to—
.The example compiles fine with a current version of LaTeX and XeLaTeX, but I could reproduce an issue with the XeLaTeX in Overleaf's TeX Live 2020 (https://www.overleaf.com/read/rggbprxmtthn). There the problem could be fixed by loading
\usepackage{fontspec}
, which is probably not that bad an idea if you use XeLaTeX or LuaLaTeX anyway.With
\usepackage{fontspec}
https://www.overleaf.com/read/zhyqysgwfynf, i.e.shows
as expected.