如何用«»定义新的数学分隔符?

如何用«»定义新的数学分隔符?

我想使用带有符号“»(法国海鸠)的特殊数学括号。但问题是,当我使用\mbox或定义它们时\text,它们会与周围的文本一起变成斜体。

\documentclass[12pt,a4paper]{letter}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\begin{document}
\newcommand{\fopen}{\mathopen\text{\guillemotleft}}
\newcommand{\fclose}{\mathclose\text{\guillemotright}}
\newcommand{\ff}[1]{\fopen #1\fclose}   

\textbf{What I have}

With normal text $\ff{O:P:Q}$ 

{\itshape With text in italic $\ff{O:P:Q}$ } (guillemots in italic)

\textbf{What it should be}

With normal text $\ff{O:P:Q}$ 

{\itshape With text in italic}  $\ff{O:P:Q}$ 
\end{document}

math_guillemots_italic

答案1

使用的字体\text是启动数学公式时有效的字体,因此在斜体上下文中它将是斜体。

改用\textnormal:

\newcommand{\fopen}{\mathopen{\textnormal{\guillemotleft}}}
\newcommand{\fclose}{\mathclose{\textnormal{\guillemotright}}}

还请注意额外的括号;这只是因为实施的原因,您不会收到错误消息。在下面的示例中,我还添加了一种方法来使命令遵守\boldmath

\documentclass[12pt,a4paper]{letter}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{pdftexcmds}

\makeatletter
\newcommand{\normalorbold}{%
  \ifnum\pdf@strcmp{\math@version}{bold}=\z@\bfseries\fi
}
\makeatother

\newcommand{\fopen}{\mathopen{\textnormal{\normalorbold\guillemotleft}}}
\newcommand{\fclose}{\mathclose{\textnormal{\normalorbold\guillemotright}}}
\newcommand{\ff}[1]{\fopen #1\fclose}   

\begin{document}

\textbf{What I have}

With normal text $\ff{O:P:Q}$ 

{\itshape With text in italic $\ff{O:P:Q}$}

\textbf{What it should be}

With normal text $\ff{O:P:Q}$ 

{\itshape With text in italic}  $\ff{O:P:Q}$ 

{\boldmath $\ff{O:P:Q}$}

\end{document}

在此处输入图片描述

如果你不缺少符号字体,你可以定义一个:

\documentclass[12pt,a4paper]{letter}
\usepackage[T1]{fontenc}
\usepackage{amsmath}

\DeclareSymbolFont{supplsymbols}{T1}{\familydefault}{m}{n}
\SetSymbolFont{supplsymbols}{bold}{T1}{\familydefault}{bx}{n}

\DeclareMathSymbol{\fopen}{\mathopen}{supplsymbols}{19}
\DeclareMathSymbol{\fclose}{\mathclose}{supplsymbols}{20}
\newcommand{\ff}[1]{\fopen #1\fclose}   

\begin{document}

\textbf{What I have}

With normal text $\ff{O:P:Q}$ 

{\itshape With text in italic $\ff{O:P:Q}$}

\textbf{What it should be}

With normal text $\ff{O:P:Q}$ 

{\itshape With text in italic}  $\ff{O:P:Q}$ 

{\boldmath $\ff{O:P:Q}$}

\end{document}

相关内容