Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I just learned about \detokenize, so this question is likely a naive one.

Nonetheless, based on what I thought that I understood about \detokenize, I would have expected \detokenize{_} to render as _.

However, when I compile the following MWE, \detokenize{_} renders as something that seems to be U+05C4 U+02D9 (see @Qrrbrbirlbel's comment).

\documentclass{article}

\begin{document}

A\detokenize{_}B

\end{document}

enter image description here

However, when I add \usepackage[T1]{fontenc} to the preamble, everything works as expected.

\documentclass{article}

\usepackage[T1]{fontenc}

\begin{document}

A\detokenize{_}B

\end{document}

enter image description here

What's going on here? My .tex file is UTF-8 encoded, and I'm compiling on a Mac (OS X 10.9.1) with TeXShop (v. 3.26) if any of that is relevant here.

share|improve this question
3  
There’s no _ in the OT1 encoding. It is at position 0x5F (ASCII) in T1. At this position is ˙ in OT1. –  Qrrbrbirlbel Dec 20 '13 at 5:37
    
@Qrrbrbirlbel Ah, that would make sense. I take it OT1 font encoding is the default for LaTeX? I wasn't aware of that. Is that also true for XeLaTeX? At any rate, if you want to make this an answer, I'll happily accept it. –  Adam Liter Dec 20 '13 at 5:39
1  
Normally one doesn't load a fontencoding manually with XeTeX. Using package fontspec is the standard, which loads en encoding called eu1, giving you a wider support. Frequently loaded packages: Differences between pdfLaTeX and XeLaTeX –  Johannes_B Dec 20 '13 at 8:27
1  
\string_ is easier than \detokenize{_}, isn't it? But \_ is even easier (and works also with OT1). –  egreg Dec 20 '13 at 10:39
    
@egreg For me, \string_ still produces ˙ unless \usepackage[T1]{fontenc} is loaded. And \_ isn't an option in this case. (This question arose as a result of one of the answers to my question about DOIs and BibTeX.) –  Adam Liter Dec 20 '13 at 16:54
show 3 more comments

1 Answer 1

up vote 1 down vote accepted

As Qrrbrbirlbel points out in the comments, there is no _ in OT1 encoding, which is the default font encoding for LaTeX.

Yet, in T1 encoding, _ is at 5xF:

enter image description here

Which is where ˙ is at in OT1 encoding:

enter image description here

Thus, without specifying the output font encoding to be T1 by declaring \usepackage[T1]{fontenc} in the preamble, the output will be ˙ instead of _.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.