2

I know I should provide a minimum working example, but that would be very complex for me. So perhaps a kind reader could point me to a possible source of this puzzling corruption. I searched here and elsewhere but couldn't find anything relevant. (Perhaps my search skills need a reboot?)

My document has has a footnote generated by the following code excerpt —

... \footnote{As of 2012, the smallest
non-Hispanic white percentages were in Hawaii (22.8\%), D.C. (35.3\%),
California (35.2\%), New Mexico (39.7\%), Texas (44.3\%), and then Nevada (52.7\%). 
Source: https://en.wikipedia.org/wiki/List_of_U.S._states_by_non-Hispanic_white_population}

That code produces odd anomalies in the pdf when compiled (XeLaTeX), with the underscore character gone and the following letter rendered as a subscript, and the hyphen magically becoming a dash:

footnote with unexplained oddities

The preamble looks like this —

\documentclass[letterpaper,10pt]{scrbook}
\usepackage{balance} 
\usepackage[ascii]{inputenc}
\usepackage{multicol,lipsum} 
\usepackage{blindtext}
\usepackage[protrusion=false,expansion]{microtype}
\usepackage{fontspec} % allow use of system fonts
\usepackage[fontsize=10pt,baseline=12pt]{grid} 
\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc} 
%\usepackage[english]{babel}

\renewcommand{\chaptername}{} 
\renewcommand{\thechapter}{} 
\setmainfont{Alegreya}%{Times New Roman}
\usepackage[top=1in,bottom=0.5in,left=2.75cm,right=1.75cm,includehead,head=12pt,headsep=12pt,includefoot,foot=0.5in,footskip=0.9602in,twoside]{geometry}
\setlength{\columnsep}{1.8em}
\usepackage{imakeidx}
\makeindex  

Thanks for any help or suggestions.

7
  • 4
    you would have had an error message about math mode. Never use a pdf file after any error. You need \_ to get a text underscore character. Mar 16, 2021 at 17:03
  • 2
    Load \usepackage{hyperref} or \usepackage{url} and then use \url to mark up URLs: \footnote{As of 2012, the smallest non-Hispanic white percentages were in Hawaii (22.8\%), D.C. (35.3\%), California (35.2\%), New Mexico (39.7\%), Texas (44.3\%), and then Nevada (52.7\%). Source: \url{https://en.wikipedia.org/wiki/List_of_U.S._states_by_non-Hispanic_white_population}} (There should have been an error message about ! Missing $ inserted. at the _: Never ignore error messages! If you have an issue look at the error messages first.)
    – moewe
    Mar 16, 2021 at 17:06
  • 1
    Unrelated, but youu are using fontspec so must be using luatex or xelatex so never use inputenc so remove \usepackage[ascii]{inputenc} Mar 16, 2021 at 17:08
  • With XeLaTeX you also do not want to load fontenc, so remove \usepackage[T1]{fontenc}.
    – moewe
    Mar 16, 2021 at 17:08
  • 1
    Slightly related: do you see how Mico was able to give a 10 line minimal working example after all?
    – Teepeemm
    Mar 16, 2021 at 17:24

1 Answer 1

2

I suggest you load the xurl package and encase the URL string in a \url wrapper. Observe that xurl allows URL strings to be line-broken at any place.

And, since you employ the fontspec package, you should not load the fontenc and inputenc packages. Just make sure that the input file is UTF8-encoded, as that's the one and only input encoding recognized by both XeTeX and LuaTeX.

enter image description here

\documentclass[letterpaper,10pt]{scrbook}
\usepackage{microtype}
\usepackage{fontspec} 
\setmainfont{Alegreya}
\usepackage{xurl}
\setlength\textheight{2.5cm} % just for this example
\begin{document}
\dots~various facts.\footnote{As of 2012, the smallest non-Hispanic white percentages were in Hawaii (22.8\%), D.C. (35.3\%), California (35.2\%), New Mexico (39.7\%), Texas (44.3\%), and Nevada (52.7\%). 
Source: \url{https://en.wikipedia.org/wiki/List_of_U.S._states_by_non-Hispanic_white_population}}
\end{document}

You must log in to answer this question.

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