通貨記号: フランスフラン II

通貨記号: フランスフラン II

これは次の質問に対するフォローアップです通貨記号: フランスフラン

次の例を考えてみましょう。

\documentclass{article}

\usepackage{fontspec}
\usepackage{siunitx}

\DeclareRobustCommand*{\myfranc}{%
  \begingroup
    \fontspec{FreeSerif.otf}%
    ^^^^20a3%
  \endgroup
}
\DeclareSIUnit{\franc}{\myfranc}

\setmainfont[
  BoldFont = lmroman10-bold.otf,
  ItalicFont = lmroman10-italic.otf,
  BoldItalicFont = lmroman10-bolditalic.otf,
  SlantedFont = lmromanslant10-regular.otf,
  BoldSlantedFont = lmromanslant10-bold.otf,
  SmallCapsFont = lmromancaps10-regular.otf
]{lmroman10-regular.otf}


\begin{document}

\SI{1000}{\franc}

\end{document}

これは(ハイコ・オベルディークの最後の提案である)答え) は以前は機能していましたが、現在は機能しません。数量のみが印刷され、単位 (フランス フラン記号) は印刷されません。どうすれば修正できますか?

また、次のフォント警告を削除するにはどうすればよいですか?

\normalsize入力行 26 の数式モードではコマンドが無効です。

答え1

このコマンドは\fontspecドキュメント内で使用しないでください。フォント ファミリを定義してそれを使用してください。

\documentclass{article}

\usepackage{fontspec}
\usepackage{siunitx}

\DeclareRobustCommand*{\myfranc}{%
  \mbox{\freeserif^^^^20a3}%
}
\DeclareSIUnit{\franc}{\myfranc}

\setmainfont[
  BoldFont = lmroman10-bold.otf,
  ItalicFont = lmroman10-italic.otf,
  BoldItalicFont = lmroman10-bolditalic.otf,
  SlantedFont = lmromanslant10-regular.otf,
  BoldSlantedFont = lmromanslant10-bold.otf,
  SmallCapsFont = lmromancaps10-regular.otf
]{lmroman10-regular.otf}
\newfontfamily{\freeserif}{FreeSerif.otf}

\begin{document}

\SI{1000}{\franc}

\end{document}

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

必要に応じて直接入力することもできます。

\documentclass{article}

\usepackage{fontspec}
\usepackage{siunitx}
\usepackage{newunicodechar}

\setmainfont[
  BoldFont = lmroman10-bold.otf,
  ItalicFont = lmroman10-italic.otf,
  BoldItalicFont = lmroman10-bolditalic.otf,
  SlantedFont = lmromanslant10-regular.otf,
  BoldSlantedFont = lmromanslant10-bold.otf,
  SmallCapsFont = lmromancaps10-regular.otf
]{lmroman10-regular.otf}
\newfontfamily{\freeserif}{FreeSerif.otf}

\newunicodechar{₣}{\text{\freeserif ₣}}
\newcommand{\FF}{₣}
\DeclareSIUnit{\franc}{\FF}

\begin{document}

\SI{1000}{\franc} is 1000\,₣ or \SI{1000}{₣}

\end{document}

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

答え2

問題は、siunitxモードオプションの標準設定を から に切り替えtextますmath

\documentclass{article}

\usepackage{fontspec}
\usepackage{siunitx}

\DeclareRobustCommand*{\myfranc}{% thanks to egreg and Manuel
  \begingroup
   \freeserif^^^^20a3%
  \endgroup
}
\DeclareSIUnit[mode = text]{\franc}{\myfranc}

\newfontfamily{\freeserif}{FreeSerif.otf}

\begin{document}

\SI{1000}{\franc}

\end{document}

出力

関連情報