unicode-math로 \boldmath 글꼴을 어떻게 설정할 수 있나요?

unicode-math로 \boldmath 글꼴을 어떻게 설정할 수 있나요?

Linux Libertine에서 문서를 조판하려고 하는데 수학 모드에서도 영숫자 글꼴을 사용하고 싶습니다. 와 같은 패키지와의 호환성을 위해 명시적으로 와 같은 알파벳을 지정해야 하기 때문에 unicode-math, not 을 사용하고 있습니다 . 나는 그것을 할 수 있는 방법을 찾지 못했습니다 . 제가 사용하는 엔진은 XeLaTeX 입니다. 처음에는 TeX Gyre Pagella Math를 기호 등의 완전한 수학 글꼴로 지정했습니다. 이후 선언에서는 텍스트 문자의 글꼴을 Libertine으로 덮어쓰도록 하고 싶습니다.mathspecmathuphepnamesmathspec

아래 MWE에서 설명한 몇 가지 문제를 발견했습니다.

  1. 스위치 \boldmath는 아무 것도 하지 않습니다.
  2. 숫자는 볼드체와 이탤릭체로 올바르게 렌더링되지 않고 문자만 표시됩니다.
  3. \mathbf(MWE의 마지막 "A = 1")은 Libertine이 아닌 Pagella에서 렌더링됩니다.

나는 이미 선언 /{latin,Latin,num}에 추가를 시도했지만 range성공하지 못했습니다. 내가 여기서 무엇을 놓치고 있는 걸까요?

\documentclass{minimal}

\usepackage{fontspec}
\usepackage{unicode-math}

\setmainfont[%
    Ligatures=TeX,
    BoldFont=LinLibertine_RB.otf,
    ItalicFont=LinLibertine_RI.otf,
    BoldItalicFont=LinLibertine_RBI.otf]
    {LinLibertine_R.otf}

\setmathfont{texgyrepagella-math.otf}

\setmathfont[range=\mathup]{LinLibertine_R.otf}
\setmathfont[range=\mathbf]{LinLibertine_RB.otf}
\setmathfont[range=\mathit]{LinLibertine_RI.otf}
\setmathfont[range=\mathbfit]{LinLibertine_RBI.otf}

\begin{document}
    \begin{tabular}{lll}
        Text     & A = 1               & \textit{B = 2}\\
        Textbf   & \textbf{A = 1}      & \textbf{\textit{B = 2}}\\
        Math     & $A = 1$             & $\mathit{B = 2}$\\
        Boldmath & {\boldmath $A = 1$} & {\boldmath $\mathit{B = 2}$}\\
        Mathbf   & $\mathbf{A = 1}$    & $\mathbfit{B = 2}$\\
    \end{tabular}
\end{document}

여기에 이미지 설명을 입력하세요

글꼴을 변경하지 않으면 모든 것이 괜찮아 보입니다.

\documentclass{minimal}

\begin{document}
    \begin{tabular}{lll}
        Text     & A = 1               & \textit{B = 2}\\
        Textbf   & \textbf{A = 1}      & \textbf{\textit{B = 2}}\\
        Math     & $A = 1$             & $\mathit{B = 2}$\\
        Boldmath & {\boldmath $A = 1$} & {\boldmath $\mathit{B = 2}$}\\
    \end{tabular}
\end{document}

여기에 이미지 설명을 입력하세요

답변1

나에게 맞는 솔루션을 찾았습니다. 나는 version=boldDavid가 제안한 대로 를 가지고 놀기 시작했지만 계속해서 바뀌었습니다.모두내 수학 모드 텍스트는 굵게 표시됩니다. 결국 파일 이름에서 시스템 글꼴 이름으로 전환했습니다. (처음에는 여러 다른 컴퓨터에서 동일한 문서를 작업하고 있기 때문에 이를 피하고 싶었습니다.) 시스템 글꼴 이름을 사용하면 \boldmath 즉시 자동으로 작업됩니다. 또한 \mathbfup가 대신 지정되어야 한다는 것을 알았습니다 \mathbf.

시스템 글꼴 이름을 사용할 때의 또 다른 문제는 어떤 이유에서든 약간 굵은 Libertine 스타일이 기본적으로 굵은 글꼴로 로드된다는 것입니다. 이것이 BoldFont아래 MWE의 사양 에 대한 이유입니다 .

해결책은 완벽하지 않습니다. 에서도 수학 모드의 모든 숫자가 수직으로 렌더링되는 것을 볼 수 있습니다 \mathit. 또한 안의 숫자는 \mathbfit굵게 표시되지 않습니다. 하지만 모든 글꼴이 정확하고 내 목적에 충분합니다.

\documentclass{minimal}

\usepackage{fontspec}
\usepackage{unicode-math}

\setmainfont[
    BoldFont=Linux Libertine Bold,
    BoldItalicFont=Linux Libertine Bold Italic]
    {Linux Libertine}

\setmathfont{TeX Gyre Pagella Math}

\setmathfont[range=\mathup,
    BoldFont=Linux Libertine Bold,
    BoldItalicFont=Linux Libertine Bold Italic]
    {Linux Libertine}
\setmathfont[range=\mathit,
    BoldFont=Linux Libertine Bold Italic]
    {Linux Libertine Italic}
\setmathfont[range=\mathbfup]{Linux Libertine Bold}
\setmathfont[range=\mathbfit]{Linux Libertine Bold Italic}

\begin{document}
    \begin{tabular}{lll}
        ~        &\ Regular             &\ Italic\\
        Text     &\ A = 1               &\ \textit{A = 1}\\
        Textbf   &\ \textbf{A = 1}      &\ \textbf{\textit{A = 1}}\\
        Math     &\ $A = 1$             &\ $\mathit{A = 1}$\\
        Boldmath &\ {\boldmath $A = 1$} &\ {\boldmath $\mathit{A = 1}$}\\
        Mathbf   &\ $\mathbf{A = 1}$    &\ $\mathbfit{A = 1}$\\
    \end{tabular}
\end{document}

여기에 이미지 설명을 입력하세요

답변2

tg85는 언급했다그가 자신의 질문에 대해 제공한 답변에는 두 가지 문제가 있습니다.

해결책은 완벽하지 않습니다. 에서도 수학 모드의 모든 숫자가 수직으로 렌더링되는 것을 볼 수 있습니다 \mathit. 또한 안의 숫자는 \mathbfit굵게 표시되지 않습니다. 하지만 모든 글꼴이 정확하고 내 목적에 충분합니다.

그만큼유니코드 수학수동(그림 7)은 "이탤릭체에서도 항상 수직 글꼴에서 가져와야 하기 때문에" 실제로 숫자에 대해 수직 모양을 의도적으로 선택했다고 명시합니다. 이 설명에 따르면 유니코드는 이탤릭체 숫자에 대한 슬롯을 정의하지 않는 반면 굵은 숫자, 산세리프 숫자 등에 대한 슬롯은 정의하는 것 같습니다.https://en.wikipedia.org/wiki/Mathematical_operators_and_symbols_in_Unicode#Mathematical_Alphanumeric_Symbols_block.

그러나 나는 여전히 누군가가 생산한 조판을 원한다는 것을 이해합니다.유니코드 수학\mathit{1}이탤릭체 숫자 1을 생성하는 원래 LaTeX 기반 조판과 일치합니다 . 따라서 다음에서 영감을 받아tg85의 코드, 저는 이 두 가지 문제를 해결하는 솔루션을 생각해 냈습니다(LuaLaTeX에서도 작동함):

% !TEX program = xelatex


\documentclass{minimal}


\usepackage{ifthen}
\usepackage[svgnames]{xcolor}

\usepackage[
   mathit = sym, mathup = sym, mathbf = sym,
   math-style = ISO, bold-style = ISO
]{unicode-math}

\setmainfont{LinLibertine_R.otf}[
   ItalicFont = LinLibertine_RI.otf,
   BoldFont = LinLibertine_RB.otf,
   BoldItalicFont = LinLibertine_RBI.otf
]
\setmonofont{FiraMono-Medium.otf}[
   Scale = 0.81,
   Color = DarkBlue
]

\setmathfont{XITSMath-Regular.otf}[
   BoldFont = XITSMath-Bold.otf
]
\setmathfont{XITSMath-Regular.otf}[
   version = mathitVersion
]
\setmathfont{XITSMath-Regular.otf}[
   version = mathbfitVersion
]
\setmathfont{XITSMath-Bold.otf}[
   version = boldmathVersion
]

\setmathfont{LinLibertine_R.otf}[
   range = up/{num, latin, Latin, greek, Greek},
   BoldFont = LinLibertine_RB.otf
]
\setmathfont{LinLibertine_RI.otf}[
   range = it/{num, latin, Latin, greek, Greek},
   BoldFont = LinLibertine_RBI.otf,
   NFSSFamily = mathitalic
]
\setmathfont{LinLibertine_RBI.otf}[
   range = bfit/{latin, Latin, greek, Greek},
   NFSSFamily = mathbolditalic
]
\setmathfont{LinLibertine_RB.otf}[
   range = bfup/{num, latin, Latin, greek, Greek}
]

\newif \ifBoldMath \BoldMathfalse
\let \mathversionorig \mathversion
\renewcommand{\mathversion}[1]{%
   \ifthenelse{\equal{#1}{bold}}{%
      \BoldMathtrue%
   }{%
      \BoldMathfalse%
   }%
   \mathversionorig{#1}%
}

\AtBeginDocument{%
   \let \mathitorig \mathit%
   \renewcommand{\mathit}[1]{%
      \ifBoldMath%
         \textbf{%
            \SetSymbolFont{__um_fam1}{boldmathVersion}{TU}{mathbolditalic}{b}{it}%
            \SetSymbolFont{__um_fam2}{boldmathVersion}{TU}{mathbolditalic}{b}{it}%
            \mathversion{boldmathVersion}%
            \(\mathitorig{#1}\)%
         }
      \else%
         \textit{%
            \SetSymbolFont{__um_fam1}{mathitVersion}{TU}{mathitalic}{m}{it}%
            \mathversion{mathitVersion}%
            \(\mathitorig{#1}\)%
         }%
      \fi%
   }%
   \let \mathbfitorig \mathbfit%
   \renewcommand{\mathbfit}[1]{{%
      \textbf{%
          \SetSymbolFont{__um_fam1}{mathbfitVersion}{TU}{mathbolditalic}{b}{it}%
          \mathversion{mathbfitVersion}%
          \(\mathbfitorig{#1}\)%
      }%
   }}%
}

\newcommand{\testUnicodeMath}{%
   \bigskip
   \begin{tabular}{l @{\quad}l @{\quad} l @{\quad} l @{\quad} l}
       Row
       & Math version/alphabet
       & Regular
       & Upright
       & Italic \\[\medskipamount]
       1
       & Text
       & A = 1a
       & \textup{B = 2b}
       & \textit{C = 3c} \\
       2 &
       \texttt{\textbackslash textbf}
       & \textbf{A = 1a}
       & \textbf{\textup{B = 2b}}
       & \textbf{\textit{C = 3c}} \\
       3
       & \texttt{\textbackslash mathversion\{normal\}} (default)
       & $A = 1a + \beta \times \Gamma \int_{-\infty}^{\infty} \frac{\mathup{d}x}{2}$
       & $\mathup{B = 2b + \beta \times \Gamma}$
       & $\mathit{C = 3c + \beta \times \Gamma}$ \\
       4
       & \texttt{\textbackslash mathversion\{bold\}}/\texttt{\textbackslash boldmath}
       & \boldmath $A = 1a + \beta \times \Gamma \int_{-\infty}^{\infty} \frac{\mathup{d}x}{2}$
       & \boldmath $\mathup{B = 2b + \beta \times \Gamma}$
       & \boldmath $\mathit{C = 3c + \beta \times \Gamma}$ \\
       5
       & \texttt{\textbackslash mathbf}/\texttt{\textbackslash mathbfup}/\texttt{\textbackslash mathbfit}
       & $\mathbf{A = 1a + \beta \times \Gamma \int_{-\infty}^{\infty} \frac{\mathup{d}x}{2}}$
       & $\mathbfup{B = 2b + \beta \times \Gamma}$
       & $\mathbfit{C = 3c + \beta \times \Gamma}$ \\
   \end{tabular}%
   \bigskip
   \bigskip
}


\begin{document}

\testUnicodeMath

\textit{Check that everything works properly by invoking it a~second time:}

\testUnicodeMath

\textit{Check that everything works properly by invoking it a~third time:}

\testUnicodeMath

\end{document}

그러면 다음과 같은 출력이 생성됩니다. 테이블 행 3의 "3"은 이제 이탤릭체로 표시되고 테이블 행 4와 5에서는 굵은 이탤릭체로 표시됩니다.

\mathit 및 \mathbfit 수정됨

\mathversion{bold}또한 / \boldmath\mathbf/ \mathbfup/ 사이의 대조에 유의하세요 \mathbfit. 전자는 모든 연산자, 적분 등을 굵게 표시하는 반면, 후자는 문자와 숫자에만 영향을 미칩니다.

답변3

amsbsy 및 \pmb 패키지를 사용하면 굵은 글씨가 표시되는 것 같습니다.

\documentclass{minimal}

\usepackage{fontspec}
\usepackage{unicode-math}
\usepackage{amsbsy}

\setmainfont[%
Ligatures=TeX,
BoldFont=LinLibertine_RB.otf,
ItalicFont=LinLibertine_RI.otf,
BoldItalicFont=LinLibertine_RBI.otf]
{LinLibertine_R.otf}

\setmathfont{texgyrepagella-math.otf}

\setmathfont[range=\mathup]{LinLibertine_R.otf}
\setmathfont[range=\mathbf]{LinLibertine_RB.otf}
\setmathfont[range=\mathit]{LinLibertine_RI.otf}
\setmathfont[range=\mathbfit]{LinLibertine_RBI.otf}

\begin{document}
\begin{tabular}{lll}
    Text     & A = 1               & \textit{B = 2}\\
    Textbf   & \textbf{A = 1}      & \textbf{\textit{B = 2}}\\
    Math     & $A = 1$             & $\mathit{B = 2}$\\
    Boldmath & { $\pmb{A = 1}$} & {$\pmb{\mathit{B = 2}}$}\\
    Mathbf   & $\mathbf{A = 1}$    & $\mathbfit{B = 2}$\\
\end{tabular}
\end{document}

여기에 이미지 설명을 입력하세요

답변4

또는xelatexlualatex

\documentclass{standalone}
\usepackage{hepparticles}
\usepackage{hepnames}
\usepackage[math-style=ISO]{unicode-math}
\usepackage{libertinus}
\usepackage{array}
\begin{document}

\tabcolsep=10pt
    \begin{tabular}{>{\ttfamily\textbackslash}lll}
    normalfont & Regular           &\itshape Italic\\
    textnormal & A = 1             & \textit{A = 1}\\
    textbf     & \textbf{A = 1}    & \textbf{\textit{A = 1}}\\
    mathup     & $\mathup{A} = 1$  & $A = 1$\\
    symbf      & $\symbfup{A = 1}$ & $\symbfit{A = 1}$\\
    mathbf     & $\mathbf{A = 1}$  & $\mathbfit{A = 1}$\\
\end{tabular}

\end{document}

여기에 이미지 설명을 입력하세요

관련 정보