Search code examples
latexpdflatexbibtexmiktex

Underline function not working in MiKTeX?


This seems ridiculous but I'm using LaTeX for the first time in a while and when I attempt to underline like so:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
...
\begin{document}
\maketitle
...
\subsection{}
\underline{ActorName} | Phone, Address, AgentName, Appears-In_Scene
\break
...
\end{document}

I get a math mode error:

! Missing $ inserted.
<inserted text> 
                $
l.15 ...me} Phone, Address, AgentName, Appears-In_
                                                  Scene

Any idea what is causing this and how to fix it? I am not opening a math statement anywhere. Also using BibTeX but I don't think that matters.


Solution

  • I am not opening a math statement anywhere.

    Well, that's the problem. You use a _ which is a command which must only be used in math mode to write underscores. If you want to write a _, you can use \textunderscore or escape the underscore with \_

    \documentclass{article}
    \usepackage[utf8]{inputenc}
    \usepackage{graphicx}
    
    
    \title{text}
    \author{names}
    
    \begin{document}
    \maketitle
    ...
    \subsection{}
    \underline{ActorName} | Phone, Address, AgentName, Appears-In\textunderscore Scene
    \break
    ...
    \end{document}