17

I have the following code:

\documentclass[11pt]{article}

\usepackage{enumerate}
\usepackage{amsmath}
\newenvironment{italic}{\begin{quote}\itshape}{\end{quote}}
\DeclareMathOperator{\rad}{rad}

\begin{document}

\begin{italic}
blablabla
    \begin{displaymath}
    \rad(R)=\{x\in R\mid x^n=0 \text{ where we consider } n\geq 1\}
    \end{displaymath}
more blablabla

    \begin{enumerate}
        \item $x^n$ with $n=1$
        \item $y^m$ with $m=2$
    \end{enumerate}

\end{italic}

\end{document}

I'd like the blablabla to be italic, but the text in the mathematical environment (for example "where we consider" and "with") shouldn't be. In my document, I have quite a lot of these blablabla's between mathematical environments, so that's the reason why I use the self-defined italic environment: to save some time and don't have to use \textit or \itshape all the time.

How can I solve this? Is this a good approach?


Edit: I've updated my question and changed the title, because the code I gave in the beginning didn't really reflect my situation. My mistake... I've used the tip to declare rad as a mathematical operator.

5
  • Isn't amsmath needed to use \text?
    – Ruben
    Commented Nov 30, 2013 at 23:53
  • @Jeroen Are you trying to write the statement of a theorem?
    – egreg
    Commented Dec 1, 2013 at 0:23
  • @egreg: Well, it's the formulation of an exercise, so it's not really a theorem.
    – Jeroen
    Commented Dec 1, 2013 at 0:25
  • According to the standard typesetting rules, the words ”where we consider” should use the current font, italic in this case. Not “rad”, which is a math symbol and must be upright.
    – egreg
    Commented Dec 1, 2013 at 0:33
  • @egreg: Really? That would solve my problem immediately! Where can I actually read these typesetting rules? Everyone talks about them, but I don't know where to find them... (sounds stupid)
    – Jeroen
    Commented Dec 1, 2013 at 0:42

3 Answers 3

17

The \textit macro does not generally control the appearance of the text in the math environment. That's done separately.

In math mode you can use

\mathrm{rad}

Or if this is to be the name of a function you can load the amsmath package in the preamble

\usepackage{amsmath}

and then in the body of the text call

\operatorname{rad}

If this is something you will want to call repeatedly you can define a command to accomplish this:

\usepackage{amsmath}
\DeclareMathOperator{\rad}{rad}

and then in the body of the document you can write

\[
  \rad(R)=\{x\in R\mid x^n=0 \text{ with }n\geq 1\}
\]

If additionally you wish the with not to be set in italics, you can do something like

\text{\normalfont\ with }

or

\textnormal{ with }

You need to make this change within \text{...} because it inherits the style of the fonts outside of the math environment.

enter image description here

You should notice that \normalfont is a switch command like \bfseries which remains in effect until the end of the current group. As \textbf{...} corresponds to {\bfseries ....}, \textnormal{...} corresponds to {\normalfont ...}.

5

To answer your first question: It does not work because you are in math-mode. On the other hand, if you are not in math-mode, something like

\textit{Blablabla \normalfont{Normalfont Bla} More Bla}

won't work too because normalfont does not take an argument. Try this one to see the difference:

\documentclass{article}

\begin{document}
\textit{Blablabla {\normalfont Normalfont Bla} More Bla}
\end{document}

Moreover you don't need to use math in \textit:

\documentclass[11pt]{article}

\begin{document}
\textit{blablabla}
\begin{displaymath}
  \mathrm{rad}(R)=\{x\in R\mid x^n=0 \text{ with } n\geq 1\}
\end{displaymath}
\end{document}

Edit

Regarding your edit:

\documentclass[11pt]{article}
\usepackage{amsmath}
\let\AMStext\text
\newenvironment{italic}
  {\renewcommand{\text}[1]{\AMStext{\normalfont ##1}}
  \begin{quote}\itshape}
  {\end{quote}}
\DeclareMathOperator{\rad}{rad}

\begin{document}
\begin{italic}
blablabla
  \begin{displaymath}
    \rad(R)=\{x\in R\mid x^n=0 \text{ where we consider } n\geq 1\}
  \end{displaymath}
more blablabla
  \begin{enumerate}
    \item $x^n \text{ with } n=1$
    \item $y^m \text{ with } m=2$
  \end{enumerate}
\end{italic}
\end{document}
2
  • 2
    One can use \textnormal
    – egreg
    Commented Nov 30, 2013 at 23:43
  • ... which takes one argument and would work in the way as \normalfont was used in the OP (just for completeness :-)
    – Ruben
    Commented Nov 30, 2013 at 23:51
2

What A. Ellet said can be simulated in a complete code snippet as follows. thm environment makes the enclosed text italic. As \text inherits the font from the outside environment, the text \text{ with } becomes italic as well. To change it back to normal font, use either \text{ \normalfont with } or \text{ \textnormal{with} }.

\documentclass[preview,border=12pt]{standalone}
\usepackage{amsmath,amssymb}

\DeclareMathOperator{\rad}{rad}
\newtheorem{thm}{Theorem}

\begin{document}
\begin{thm}[\textbackslash textnormal]
\[
  \rad(R)=\{x\in \mathbb{R}\mid x^n=0 \text{ \textnormal{with} } n\geq 1\}
\]
\end{thm}
\begin{thm}[\textbackslash normalfont]
\[
  \rad(R)=\{x\in \mathbb{R}\mid x^n=0 \text{ \normalfont with } n\geq 1\}
\]
\end{thm}
\end{document}

You can also change the symbol R by \mathbb{R} to make it clearer as a real number set. Does it seem to be more fancy?

enter image description here

Note: It is a community wiki answer, just to prevent me from getting reputation points whenever the readers vote it up.

1
  • 1
    Actually, the R marks a ring, not the real number set. :)
    – Jeroen
    Commented Dec 1, 2013 at 0:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .