2

I have a simple slide in beamer, in which I want to type an underscore with \_. However, the underscore is very far away from the text, much further, than in a normal document (not in beamer). Maybe it's due to a package I am missing, but I cannot figure it out. See for yourself, this does not look like a normal underscore (it's far below the text where it should be):

\documentclass[xcolor= pdftex, dvipsnames, table, 16pt]{beamer}
\mode<presentation>
{
    \usetheme{Default}
    \setbeamercovered{transparent}
    \usecolortheme{whale}
}

\usepackage{array}
\usepackage{booktabs}
\usepackage{mathptmx}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{adjustbox, lipsum}
\usepackage{tabularx} 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{rotating}
\usepackage{setspace}
\usepackage{makecell}

\begin{document}

\begin{frame}
    A\_B
\end{frame}

\end{document}

What am I doing wrong?

ghx
  • 423
  • Compare the outputs of the following: a) \documentclass{article}\begin{document} A\_B \end{document}, b) \documentclass{article}\usepackage[T1]{fontenc}\begin{document} A\_B\end{document} , c) \documentclass{beamer}\begin{document}\begin{frame} A\_B\end{frame} \end{document} and d) \documentclass{beamer}\usepackage[T1]{fontenc}\begin{document}\begin{frame} A\_B\end{frame}\end{document}. – leandriis Oct 03 '19 at 19:10
  • https://tex.stackexchange.com/a/42817/134144 might be interesting regarding the different output when using T1 encoding. – leandriis Oct 03 '19 at 19:15
  • @leandriis ok I see the problem is related to usepackage[T1]{fontenc}. But only in beamer. In my normal document, it does not look like that. But I have loaded more packages there, so maybe there is a fix. So your recommendation is not to use that option? – ghx Oct 03 '19 at 19:20
  • No, not using \usepackage[T1]{fontenc} is not the suggested solution. Depending on what language you are writing in, it might be useful to load. Additionally, as egreg states in their anser: "So with the default OT1 encoding, the command \textunderscore (or _) is defined to produce a small rule, which is not recognized by PDF viewers as a character." – leandriis Oct 03 '19 at 19:27
  • Ok I understand, but it messes up the underscore. Is that by intention? I am writing in English. So removing \usepackage[T1]{fontenc} has worked to make the distance better, but now the underscore is very short in width. I was looking for a way to write a simple underscore like it looks for instance here: A_B. But does not seem possible so easily. – ghx Oct 03 '19 at 19:32

0 Answers0