2

I have defined a \imag command to assign the value of the imaginary unit with the font \texttt. However when I call the command \imag inside a theorem environment with the plain style the font is printed with the italic font. Does anyone know of a general way to solve this problem?

The following is a minimal compilable example

\documentclass[a4paper, 11pt]{article}

\usepackage[T1]{fontenc}      
\usepackage[utf8]{inputenc}     
\usepackage[english]{babel}     


% ----------------------------
% STANDARD PACKAGES FOR MATH
% ----------------------------
\usepackage{amsmath}            % AMS Math Package
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amsthm}             % theorem formatting 
\usepackage{bm}                 % bold math
\usepackage{physics}            
% Note: "dsfont" override \mathbb{} blackboard bold font provided by "amsfonts" 


\theoremstyle{plain} % default
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}


\newcommand{\imag}{\texttt{i}}  % imaginary number


\begin{document}

\begin{theorem}[Duffy, Pan and Singleton (2000)]
    If $\vb{X}(t)$ is in the affine form, the discounted characteristic function defined as
    \begin{equation}
        \phi(\vb{u},\vb{X}(t),t,T) = \mathbb{E}^{\mathbb{Q}}\left[
        e^{-\int_{t}^{T} r(\vb{X}(s))\dd{s} + \imag \vb{u}^{T} \vb{X}(T)} \left|\right. \mathcal{F}_{t} 
        \right] ~ \forall \, \vb{u} \in \mathbb{C}^{d},
    \end{equation}
    with boundary condition
    \begin{equation}
        \phi(\vb{u},\vb{X}(T),T,T) = e^{\imag \vb{u}^{T} \vb{X}(T)},
    \end{equation}
    has a solution of the following form
    \begin{equation}\label{eq:AD_chf}
        \phi(\vb{u},\vb{X}(T),t,T) = e^{A(\vb{u},t,T) + \vb{B}(\vb{u},t,T)^{T} \vb{X}(t)}
    \end{equation}
\end{theorem}

\end{document}
4
  • 2
    No matter how you want to type the imaginary unit, \texttt{i} is not the way to go. It switches to the text font and uses that in your math environment instead of the math font. If you really want the imaginary unit in typewriter font (which is an unusual convention which I cannot really see the reason for), use \mathtt{i} (which will probably also solve your issue).
    – Gaussler
    Jun 21, 2023 at 9:39
  • 1
    Oh, and by the way, don’t use the physics package.
    – Gaussler
    Jun 21, 2023 at 9:44
  • @Gaussler Thank you very much, it works. One question Is there any particular reason why you would advise against using the physics package? It provides very useful macros to simplify the writing of equations
    – SimoPape
    Jun 21, 2023 at 9:55
  • 1
    The phycics package is very badly implemented and suggests some practices taht are not recommended (for example fence auto scaling)
    – daleif
    Jun 21, 2023 at 9:57

1 Answer 1

5

You want

\newcommand{\imag}{\mathtt{i}}

(assuming you really want such a nonstandard notation).

If you're short on math groups (you'll be informed about this by running the document), you can state \normalfont\ttfamily

\newcommand{\imag}{\text{\normalfont\ttfamily i}}

Just to comply with my personal “physics does many disputable things” and to suggest better typesetting:

\documentclass[a4paper, 11pt]{article}

\usepackage[T1]{fontenc}      
%\usepackage[utf8]{inputenc}     
\usepackage[english]{babel}     


% ----------------------------
% STANDARD PACKAGES FOR MATH
% ----------------------------
\usepackage{amsmath}            % AMS Math Package
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amsthm}             % theorem formatting 
\usepackage{bm}                 % bold math
%\usepackage{physics}            


\theoremstyle{plain} % default
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}


\newcommand{\imag}{\mathtt{i}}  % imaginary number
\newcommand{\vb}[1]{\mathbf{#1}}% might also be \bm{#1}
\newcommand{\bC}{\mathbb{C}}
\newcommand{\bE}{\mathbb{E}}
\newcommand{\bQ}{\mathbb{Q}}
\newcommand{\diff}{\mathop{}\!\mathrm{d}}

\begin{document}

\begin{theorem}[Duffy, Pan and Singleton (2000)]
If $\vb{X}(t)$ is in the affine form, the discounted characteristic function defined as
\begin{equation}
  \phi(\vb{u},\vb{X}(t),t,T) = \bE^{\bQ}
%  \left[
  \bigl[
    e^{-\int_{t}^{T} r(\vb{X}(s))\diff s + \imag \vb{u}^{T} \vb{X}(T)}
%  \;\middle|\;
  \bigm|
    \mathcal{F}_{t} 
%  \right]
  \bigr]
  \quad \forall \, \vb{u} \in \bC^{d},
\end{equation}
with boundary condition
\begin{equation}
  \phi(\vb{u},\vb{X}(T),T,T) = e^{\imag \vb{u}^{T} \vb{X}(T)},
\end{equation}
has a solution of the following form
\begin{equation}\label{eq:AD_chf}
  \phi(\vb{u},\vb{X}(T),t,T) = e^{A(\vb{u},t,T) + \vb{B}(\vb{u},t,T)^{T} \vb{X}(t)}
\end{equation}
\end{theorem}

\end{document}

I kept (commented) the \left\middle\right commands (better than your attempt, anyway), to show that \big size is really enough.

I commented out physics and defined \vb to do the same. Actually physics provides \vb*{x} to use bold italic. They should be two different commands, if it's intended to use both varieties.

Also physics defines \dd in a really strange way. I don't think it's more difficult to type in

\diff^{3} x    \diff(\cos x)

instead of

\dd[3]{x}    \dd(\cos x)

enter image description here

9
  • Good practice aside, why does \itshape apparently override \texttt?
    – Gaussler
    Jun 21, 2023 at 9:42
  • 2
    @Gaussler Because \texttt only issues \ttfamily and the font attributes are orthogonal.
    – egreg
    Jun 21, 2023 at 9:43
  • Thank you very much @egreg works very well. For the imaginary unit notation I am using the one that was imposed by my advisor so I have to like it :)
    – SimoPape
    Jun 21, 2023 at 9:57
  • Am I missing something here? Why \text in the latter example? Wouldn't \textnormal{\ttfamily} do the same?
    – daleif
    Jun 21, 2023 at 9:59
  • @daleif In math mode, \textnormal{...} does \nfss@text{\normalfont...} and \nfss@text is \text in disguise.
    – egreg
    Jun 21, 2023 at 10:06

You must log in to answer this question.

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