表格和数学中的内衬数字,文本中的旧式数字

表格和数学中的内衬数字,文本中的旧式数字

我使用的是 TeXLive 2012,在 Ubuntu 12.10 上是最新版本。当我使用libertine带有选项osfnewtxmath数学字体的软件包时,我到处都会得到旧式数字,但我只想在正文中使用它们,而不是在表格或数学模式中使用它们。以下是问题的图片和 MWE 示例图片

\documentclass[a4paper]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{tabulary}
\usepackage{textcomp}
\usepackage[osf]{libertine}
\usepackage{amsmath, amsthm}
\usepackage[cmintegrals, cmbraces, libertine]{newtxmath}
\usepackage[version=3]{mhchem}

\begin{document}
Old style numbers belong in text 0123456789.
Not in equations:
\begin{equation}
     \cee{C6H12O6 + 6O2 -> 6CO2 ^ + 6H2O ^ + \text{heat} ^}
\end{equation}
Nor in tables:
\begin{table}[!htb]
     \begin{tabulary}{\textwidth} {LCCCCR}
      \toprule
      climate &
      species &
      mean &
      median &
      standard deviation &
      number of experiments \\
      \midrule
      1 & \textit{Picea abies}  & 20,3699   & 20,0335   & 4,453 & 30 \\
      \bottomrule
      \end{tabulary}
      \caption{mean, median and standard deviation}
      \label{tab:mean}
\end{table}

\end{document}

答案1

libertine包默认已激活选项liningtabular。但在普通文本中,您通常需要proportionaloldstyle

\usepackage[oldstyle,proportional]{libertine}

不过,你不想将它们设置为包选项,而只能 newtxmath已加载以获取数学中的衬线数字。这可以通过定义\libertine@figurealign为空定义(使用 pdfLaTeX)或Proportional(使用 XeLaTeX 或 LuaLaTeX)并\libertineOsF随后调用来完成:

\usepackage{libertine}
\usepackage[cmintegrals, cmbraces, libertine]{newtxmath}
\makeatletter
\AtBeginDocument{\def\libertine@figurealign{}\libertineOsF}
\makeatother

如果您现在也希望mhchem在文本模式下有内衬数字,那么您必须设置其字体选项:

\mhchemoptions{textfontcommand=\libertineLF}

在表格中,您通常希望libertine恢复 的默认值。这可以通过在使用 pdfLaTeX 编译时重新定义\libertine@figurealignT(对于比例数字,其定义是空的)或使用 XeLaTeX 或 LuaLaTeX 重新定义为Monospaced(相对于Proportional),然后调用 switch 来实现\libertineLF。为方便起见,可以定义一个命令\libertineTabular

\makeatletter
\newcommand\libertineTabular{\def\libertine@figurealign{T}\libertineLF}
\makeatother

这个新定义的命令应该只在环境内部使用{table},或者更准确地说,本地如果您不想切换tabular整个文档的图形。

在此处输入图片描述

\documentclass[a4paper]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{tabulary}
\usepackage{textcomp}
\usepackage{amsmath, amsthm}
\usepackage{libertine}
\usepackage[cmintegrals, cmbraces, libertine]{newtxmath}
\usepackage[version=4]{mhchem}
\mhchemoptions{textfontcommand=\libertineLF}

\makeatletter
\AtBeginDocument{\def\libertine@figurealign{}\libertineOsF}
\newcommand\libertineTabular{\def\libertine@figurealign{T}\libertineLF}
\makeatother

\begin{document}
Old style numbers belong in text 0123456789. \ce{C6H12O6 + 6O2 -> 6CO2 ^ + 6H2O ^ + \text{heat} ^}
Not in equations:
\begin{equation}
  \ce{C6H12O6 + 6O2 -> 6CO2 ^ + 6H2O ^ + \text{heat} ^}
\end{equation}
Nor in tables.

\begin{table}[!htb]
  \caption{mean, median and standard deviation}
  \label{tab:mean}\libertineTabular
  \begin{tabulary}{\textwidth} {LCCCCR}
    \toprule
      climate & species & mean &  median & standard deviation & number of experiments \\
    \midrule
      1 & \textit{Picea abies}  & 20,3699   & 20,0335   & 4,453 & 30 \\
      2 & \textit{Picea abies}  & 23,9864   & 12,6398   & 7,236 & 98 \\
    \bottomrule
  \end{tabulary}
\end{table}

\[ a^2 + b^2 = c^2 \qquad 1234567890 \]
Old style numbers belong in text 0123456789.

\end{document}

答案2

  1. 使用\usepackage{libertine},然后立即\begin{document}使用\libertineOsF
  2. 之后立即\begin{table}[..]使用\libertineLF

答案3

正如@cgnieder 所指出的,正文的默认数字外观应设置为proportionalosf(旧式数字)。化学方程式应采用比例衬线数字。最后,表格应包含表格数字(等宽),但我个人认为表格中的旧式数字很好。

在下面的代码中,我定义了三个字体切换命令,可用于在某些地方设置所需的样式。然后我按照上一段所述设置样式。与 cgnieder 的答案的主要区别在于,我为所有tabulary表格设置了表格图形,而无需在每个表格上手动指定。

\documentclass[a4paper]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{tabulary}
\usepackage{textcomp}
% \usepackage{libertine}               %% to have tabular (lining) figures in chemistry equations
\usepackage[proportional]{libertine} %% to have proportional (lining) figures in chemistry equations
\usepackage{amsmath, amsthm}
\usepackage[cmintegrals, cmbraces, libertine]{newtxmath}
\usepackage[version=3]{mhchem}

\makeatletter
\newcommand\libertineTLF{\def\libertine@figurealign{T}\libertineLF}
% \newcommand\libertinePLF{\def\libertine@figurealign{}\libertineLF}    %% not needed
\newcommand\libertineTOsF{\def\libertine@figurealign{T}\libertineOsF}
\newcommand\libertinePOsF{\def\libertine@figurealign{}\libertineOsF}
\makeatother

%% to have proportional old style figures in the main text
\AtBeginDocument{\libertinePOsF}

%% to have lining figures in chemistry equations;
%% to switch between tabular and  proportional lining figures, use the `proportional` package option of libertine
\mhchemoptions{textfontcommand=\libertineTLF}

%% to have tabular figures in all tabulary environments
\usepackage{etoolbox}
\makeatletter
\pretocmd{\TY@tabular}{\libertineTOsF}{}{}  %% tabular old style figures
% \pretocmd{\TY@tabular}{\libertineTLF}{}{}   %% tabular lining figures
\makeatother


\begin{document}
Old style proportional width numbers belong in text 0123456789.
Not in equations (does not make sense chemically):
\begin{align}
     \cee{C6H12O6 + 6666O2 & -> 6666CO2 ^ + 6666H2O ^ + \text{heat} ^} \\
     \cee{C6H12O6 + 1111O2 & -> 1111CO2 ^ + 1111H2O ^ + \text{heat} ^}
\end{align}
Nor in tables:
\begin{table}[!htb]
     \begin{tabulary}{\textwidth} {LCCCCR}
      \toprule
      climate &
      species &
      mean &
      median &
      standard deviation &
      number of experiments \\
      \midrule
      1 & \textit{Picea abies}  & 20,3699   & 20,0335   & 4,453 & 30 \\
      1 & \textit{Picea abies}  & 20,3699   & 11,1111   & 4,453 & 30 \\
      9 & \textit{Picea abies}  & 20,3699   & 99,9999   & 4,453 & 30 \\
      \bottomrule
      \end{tabulary}
      \caption{mean, median and standard deviation}
      \label{tab:mean}
\end{table}
\end{document}

示例输出

相关内容