Text FormattingRemoving italics/ensuring not italic/theorem environment

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
verbatim
Posts: 4
Joined: Sun May 30, 2010 3:28 pm

Removing italics/ensuring not italic/theorem environment

Post by verbatim »

I'm trying to replace the built-in \bmod operator (which, rather unhelpfully, just types the word "mod") with a proper modulo operator: %. I'm currently using \texttt{\%}. It's not ideal (an ideal modulo operator should really be almost square, but the font used by \texttt has a very narrow and tall percent sign), but it's a lot better than the default cursive-style percent sign in latex.

The replacement works well enough in normal environments, but if I place it inside the theorem environment, it becomes italicized, which is wrong.

Any suggestions would be appreciated, ideally I'd like to use something like \ensureNotItalic{\texttt{\%}}}, but I don't know how to implement something like \ensureNotItalic.

(I'd also like to improve on the font, if anyone has suggestions for that, but getting rid of the italicization is essential.)

Here's a MWE:

\documentclass{article}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}

\newtheorem*{lem}{Lemma}
\let\bmod\undefined
\DeclareMathOperator{\bmod}{\texttt{\%}}


\begin{document}

The command \verb+\bmod+ (in math mode) should look like $\bmod$, but in the text of a theorem environment, it comes out italicized...

\begin{lem}
The extent of $\sigma_{axx}$, where $a$ and $x$ are integers, is $2x + a\bmod2$
\end{lem}

\end{document}
Last edited by verbatim on Sun Dec 19, 2010 4:35 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Removing italics/ensuring not italic/theorem environment

Post by frabjous »

The argument to \DeclareMathOperator is normally put in an upright font (witness the effects of \sin or \cos, etc.), so in this case, it should work to put simply:

Code: Select all

\DeclareMathOperator{\bmod}{\%}
Or if you want to be more explicit:

Code: Select all

\DeclareMathOperator{\bmod}{\textup{\%}}
\textup is the explicit command for "upright" (non-italic) text. (\textup is the counterpart to \textit ; \upshape is the counterpart to \itshape, etc.) Or combine the effects:

Code: Select all

\DeclareMathOperator{\bmod}{\textup{\texttt{\%}}}
verbatim
Posts: 4
Joined: Sun May 30, 2010 3:28 pm

Re: Removing italics/ensuring not italic/theorem environment

Post by verbatim »

That's exactly what I did, see the MWE.

Well, except that I switch to \texttt inside it in order to get a more appropriate looking operator. The default % sign doesn't look the least bit like a modulo operator.

edit: Posted at about the same time as the (edit to the) post above, sorry for any confusion.

Thanks, \textup does the trick. Now, if I could only find a way to use a font that actually has an appropriately shaped % sign to use as a modulo operator...
Last edited by verbatim on Sun Dec 19, 2010 4:29 am, edited 3 times in total.
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Re: Removing italics/ensuring not italic/theorem environment

Post by frabjous »

The \texttt is undoing the effects of having it inside \DeclareMathOperator, but if you want to combine the effects, you can use my last suggestion (--I edited the answer to add that suggestion, sorry).
Post Reply