Gary F.
unread,Jun 9, 2012, 4:39:35 PM6/9/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to latexus...@googlegroups.com
I am working on a document that refers to many "C" variable names, and most of those names have one/more underscores (_'s) in them. LaTeX wants to treat them as a subscript operator, unless they're escaped. There is an "underscore" package which eases the pain somewhat, but there are still important contexts where apparently the '_' must be written as '\_'. Attached is a working example, which demonstrates several problem-free usages of an un-escaped '_'.
One problem area however appears to be the use of a bare '_' within a section tittle. For example, this change results in a latex compilation error.
< \subsection{{\texttt VAR\_WITH\_UNDERSCORE}}
---
> \subsection{{\texttt VAR_WITH_UNDERSCORE}}
The underscore package reference defines a hook for explicitly defining commands that it should filter for the presence of bare _'s. Tried that:
> \newcommand{\UnderscoreCommands}{
> \do\section \do\subsection
> \do\subsubsection \do\subsubsubsection
> \do\paragraph \do\subparagraph
> }
but it did not improve the situation. The latex compilation just failed in a different way.
A few questions:
1. Is there a way to use the underscore package (alone or in combination with other packages and LaTeX code) to support the use of un-escaped _'s within sectioning commands?
2. As an alternative, is it possible to define a command, called \var{<C_variable>} that will automatically escape the _'s within the argument, and apply a suitable monospace font? For example:
\newcommand{\var}[1]{\texttt{\un_escape{\verb|#1|}}}
where \un_escape performs a character-by-character substitution of _ to \_?
3. Unrelated: I had a heck of a time getting rid of "duplicate" definition warnings for page references, and the fiddling with \pagenumbering didn't help much. In its current form it is fine and gives the result that I was expecting, except for page numbers on the index listing page. Perhaps there is way to disable those?
4. Any other suggestions for improving use and style are appreciated.
thanks,
- Gary