両方のモードで Charter の数字を取得する方法 (テキスト モードでは古いスタイル)

両方のモードで Charter の数字を取得する方法 (テキスト モードでは古いスタイル)

テキスト モードで Charter の「旧スタイル」オプションを使用し、数式モードで Charter 文字 (数字を含む) を使用するにはどうすればよいでしょうか。

提案されたソリューションは、LuaLaTeX で動作する必要があります (一部のテキスト文字は非 ASCII であり、それらの非 ASCII 文字をソース ファイルに貼り付けて、ソースを UTF-8 として保存することを好むため)。

編集:念のため、私は MiKTeX v.2.9 を使用しています。この問題を解決するにはアップグレードする必要がありますか?

非常に近づくことはできますが、すべてを一度に機能させることはできません。

MWE 1:

\documentclass[12pt,a4paper]{article}

\usepackage{amsmath}
\usepackage{fontspec}
\setmainfont{XCharter} % see https://tex.stackexchange.com/a/205558
\usepackage[oldstyle]{xcharter}

% See https://tex.stackexchange.com/a/347574 for why this is needed. 
\AtBeginDocument{%
  \Umathcode`0="7 "0 `0
  \Umathcode`1="7 "0 `1
  \Umathcode`2="7 "0 `2
  \Umathcode`3="7 "0 `3
  \Umathcode`4="7 "0 `4
  \Umathcode`5="7 "0 `5
  \Umathcode`6="7 "0 `6
  \Umathcode`7="7 "0 `7
  \Umathcode`8="7 "0 `8
  \Umathcode`9="7 "0 `9
}

\usepackage[charter]{newtxmath}

\begin{document}

Digits in plain text: 48/96=135/270.

$a=48, b=96, c=135, d=270\implies a/b=c/d.$ $8=5+3=9-1=2\times4=2^3.$

\end{document}

テキストモードでの数字はまさに私の希望どおりです。さらに、数式モードでの文字はCharterイタリック体で、これは私が望んでいたものです。しかし、数式モードでの数字はComputer Modernで、私がコードを使用しようとしたにもかかわらず、この答えは、リバティーンに関して同様の質問に答えています。

2 次

\documentclass[12pt,a4paper]{article}

\usepackage{amsmath}

\usepackage{fontspec}
\setmainfont{XCharter}[Numbers={OldStyle}] % see https://tex.stackexchange.com/a/205558
\usepackage[charter]{newtxmath}

% See https://tex.stackexchange.com/a/347574 for why this is needed. 
\AtBeginDocument{%
  \Umathcode`0="7 "0 `0
  \Umathcode`1="7 "0 `1
  \Umathcode`2="7 "0 `2
  \Umathcode`3="7 "0 `3
  \Umathcode`4="7 "0 `4
  \Umathcode`5="7 "0 `5
  \Umathcode`6="7 "0 `6
  \Umathcode`7="7 "0 `7
  \Umathcode`8="7 "0 `8
  \Umathcode`9="7 "0 `9
}

\begin{document}

Digits in plain text: 48/96=135/270.

$a=48, b=96, c=135, d=270\implies ab=cd.$ $8=5+3=9-1=2\times4=2^3.$

\end{document}

ここで、\usepackage{xcharter} ではなく \setmainfont をハッキングして、テキスト モードで旧スタイルの数字を取得しようとします。ただし、これは、パラメーター oldstyleI (oldstyle ではなく) を \usepackage{xcharter} に渡すようです。いずれにしても、結果は、テキスト モードでは旧スタイルの数字になりますが、1 には小文字の I が付きます。幸いなことに、数式モードの数字は Charter であり、これが私が求めているものです。

テキスト モードと数式モードの両方で旧式の Charter 数字を使用できればさらに便利です。そうすれば、数式モードでテーブルを配列環境として保持できます。テーブル内の数字をテキスト モードに切り替えるには、たとえば$\begin{array}{r} n \\ 1 \end{array}$を に置き換える必要があります\begin{tabular}{r} $n$ \\ 1 \end{tabular}

答え1

unicode-mathLuaLaTeX を使用しているため、互換性の問題のあるの代わりに をロードできますnewtxmath。数式には XCharter-Math フォントを使用します。

編集:コメントでは、[oldstyleI]XCharter の OpenType バージョンの文字異体 01 である の数字 1 をリクエストしました。修正バージョンを以下に示します。

\documentclass[12pt,a4paper]{article}

\usepackage{unicode-math}

\defaultfontfeatures[XCharter]{ Numbers=OldStyle,
                                CharacterVariant=1, % Change the shape of 1 in text mode
                                UprightFont=*-Roman,
                                BoldFont=*-Bold,
                                ItalicFont=*-Italic,
                                SlantedFont=*-Slanted,
                                BoldItalicFont=*-BoldItalic,
                                BoldSlantedFont=*-BoldSlanted,
                                Extension=.otf }

\setmainfont{XCharter}
\setmathfont{XCharter-Math}

\begin{document}

Digits in plain text: 48/96=135/270.

$a=48, b=96, c=135, d=270\implies ab=cd.$ $8=5+3=9-1=2\times4=2^3.$

\end{document}

XCharter サンプル

万が一、数式モードでも古い形式の数値が必要な場合は、次のコマンドを追加できます。

\setmathfont{XCharter-Roman.otf}[range={up/num},
                                 Numbers=OldStyle,
                                 CharacterVariant=01] % Change the shape of 1 in math mode

以下は PDFLaTeX で動作するバージョンです:

\documentclass[12pt,a4paper]{article}

\usepackage{amsmath}
\usepackage[charter]{mathdesign}
\usepackage[oldstyle]{xcharter}

\begin{document}

Digits in plain text: 48/96=135/270.

$a=48, b=96, c=135, d=270\implies ab=cd.$ $8=5+3=9-1=2\times4=2^3.$

\end{document}

可能な場合は LuaLaTeX を使用し、必要な場合はレガシー 8 ビット フォントの PDFLaTeX を使用することをお勧めしますunicode-math。ただし、ここでの問題は Unicode を読み取れないことだとおっしゃっているので、NFC (正規化された事前合成) UTF-8 エンコーディングで保存すれば、ドキュメントが機能する可能性は十分にあります。PDFLaTeX は Unicode 結合文字を理解できませんが、8 ビット入力エンコーディングに直接マップされる Unicode 文字であれば処理できます。

編集:

OpenType テキスト フォントを従来の Type 1 数学フォントと一緒に使用したい場合は、次のようにします。

\documentclass[12pt,a4paper]{article}

\usepackage{amsmath}
\usepackage[charter]{mathdesign}
\usepackage{fontspec}

\setmainfont{XCharter}[NFSSFamily=mdbch, Numbers=OldStyle]

\begin{document}

Digits in plain text: 48/96=135/270.

$a=48, b=96, c=135, d=270\implies ab=cd.$ $8=5+3=9-1=2\times4=2^3.$

\end{document}

答え2

を使用したくない場合は、ライニング数字付きの XCharter を使用するようにフォントunicode-mathを再定義する必要があります。operators

\documentclass[12pt,a4paper]{article}

\usepackage{amsmath}
\usepackage{fontspec}
\usepackage[charter]{newtxmath}

\setmainfont{XCharter}[Numbers={OldStyle}] % see https://tex.stackexchange.com/a/205558
\newfontfamily{\XCharterLF}{XCharter}[NFSSFamily=xcharterlf]

\DeclareSymbolFont{operators}{TU}{xcharterlf}{m}{n}

\begin{document}

Digits in plain text: 48/96=135/270.

$a=48, b=96, c=135, d=270\implies ab=cd$.

$8=5+3=9-1=2\times4=2^3$.

$\sin x$

\end{document}

ここに画像の説明を入力してください

関連情報