Alegreya 阻止嵌套的 \emph 命令按预期运行

Alegreya 阻止嵌套的 \emph 命令按预期运行

我正在使用 Alegreya 字体和 PDFLaTeX,并注意到\emph嵌套时该命令不再起作用。为了更清楚起见,以下代码:

\documentclass{book}
\usepackage{Alegreya}
\begin{document}
Normal text. \emph{Emphasized text.} \emph{Emphasized text including \emph{emphasized} text.}
\end{document}

产量:

Alegreya 阻止嵌套的 \emph 正常工作

而不是常规的嵌套行为(当选择另一种字体或不选择任何字体时):在此处输入图片描述

关于如何解决这个问题有什么想法吗?

答案1

这是 Alegreya 字体度量文件中的另一个错误。斜体或倾斜字体都没有正确的值\fontdimen1。您可以使用我为如何使用 Alegreya 字体和 pdftex 正确显示一些东欧变音符号?修改后也考虑到了中的值\fontdimen1,但您应该提交错误报告。

\documentclass{scrbook}
\usepackage[T1]{fontenc}

\DeclareFontFamily{T1}{Alegreya-LF}{}
\newcommand{\adjustalegreyaxheight}{\fontdimen5\font=\fontcharht\font`x }
\newcommand{\adjustalegreyaslant}{\fontdimen1\font=0.25pt }

\makeatletter
\let\Alegreya@@scale\@empty
%%% uncomment the next line if you want to scale the font,
%%% changing the value to what suits you
% \def\Alegreya@@scale{s*[0.9]}%
\makeatother

\DeclareFontShape{T1}{Alegreya-LF}{k}{n}{
      <-> \Alegreya@@scale Alegreya-Black-lf-t1
}{\adjustalegreyaxheight}

\DeclareFontShape{T1}{Alegreya-LF}{k}{it}{
      <-> \Alegreya@@scale Alegreya-BlackItalic-lf-t1
}{\adjustalegreyaxheight\adjustalegreyaslant}

\DeclareFontShape{T1}{Alegreya-LF}{k}{sl}{
      <-> ssub * Alegreya-LF/k/it
}{\adjustalegreyaxheight\adjustalegreyaslant}

\DeclareFontShape{T1}{Alegreya-LF}{b}{n}{
      <-> \Alegreya@@scale Alegreya-Bold-lf-t1
}{\adjustalegreyaxheight}

\DeclareFontShape{T1}{Alegreya-LF}{b}{it}{
      <-> \Alegreya@@scale Alegreya-BoldItalic-lf-t1
}{\adjustalegreyaxheight\adjustalegreyaslant}

\DeclareFontShape{T1}{Alegreya-LF}{b}{sl}{
      <-> ssub * Alegreya-LF/b/it
}{\adjustalegreyaxheight\adjustalegreyaslant}

\DeclareFontShape{T1}{Alegreya-LF}{m}{n}{
      <-> \Alegreya@@scale Alegreya-Regular-lf-t1
}{\adjustalegreyaxheight}

\DeclareFontShape{T1}{Alegreya-LF}{m}{it}{
      <-> \Alegreya@@scale Alegreya-Italic-lf-t1
}{\adjustalegreyaxheight\adjustalegreyaslant}

\DeclareFontShape{T1}{Alegreya-LF}{m}{sl}{
      <-> ssub * Alegreya-LF/m/it
}{\adjustalegreyaxheight\adjustalegreyaslant}

\DeclareFontShape{T1}{Alegreya-LF}{bx}{sl}{
      <-> ssub * Alegreya-LF/b/sl
}{\adjustalegreyaxheight\adjustalegreyaslant}

\DeclareFontShape{T1}{Alegreya-LF}{bx}{n}{
      <-> ssub * Alegreya-LF/b/n
}{\adjustalegreyaxheight}

\DeclareFontShape{T1}{Alegreya-LF}{bx}{it}{
      <-> ssub * Alegreya-LF/b/it
}{\adjustalegreyaxheight\adjustalegreyaslant}

\usepackage{Alegreya}

\begin{document}

Normal text. \emph{Emphasized text.} \emph{Emphasized text including \emph{emphasized} text.}


The x-height: \expandafter\texttt\expandafter{\the\fontdimen5\font}

The height of `x': \expandafter\texttt\expandafter{\the\fontcharht\font`x}

Rodion \^{S}edrin

\u{U}ladz\`{i}m\`{i}r Damarackij

V\^{a}\v{c}\`{e}sla\u{u} Kuzn\^{a}co\u{u} 

\footnotesize

The x-height: \expandafter\texttt\expandafter{\the\fontdimen5\font}

The height of `x': \expandafter\texttt\expandafter{\the\fontcharht\font`x}

Rodion \^{S}edrin

\u{U}ladz\`{i}m\`{i}r Damarackij

V\^{a}\v{c}\`{e}sla\u{u} Kuzn\^{a}co\u{u} 

\end{document}

在此处输入图片描述

为了完整性,我将这些内容保留在另一个答案中。

解释

为了判断字体是否倾斜,LaTeX 会检查\fontdimen1当前字体中的参数。如果该参数为零,则 LaTeX 假定字体是直立的。

更灵活的黑客技术

这里的代码应该处理图形的所有四种组合(衬线/旧式、表格/非表格),以便Alegreya可以使用任何选项调用。

\documentclass{scrbook}
\usepackage[T1]{fontenc}

%%%%% HACK BEGINS
\def\adjustalegreyaslant{\fontdimen1\font=0.25pt }
\def\adjustalegreyaxheight{}
%%%% remove the following when you have Alegreya
%%%% with the date 2014-01-18 (or later)
\def\adjustalegreyaxheight{\fontdimen5\font=\fontcharht\font`x }

\begingroup\makeatletter
%%% scale option
\let\alegreyascale\@empty
%%% uncomment the next line if you want to scale the font,
%%% changing the value to what suits you
% \def\alegreyascale{s*[0.9]}
%% spaces and end of lines are ignored
\catcode`\ =9 \endlinechar=-1
\newcommand\adjustallalegreyafamilies[2]{
  \def\alegreyasuffix{#1}\def\alegreyainfix{#2}
  \DeclareFontFamily{T1}{Alegreya-\alegreyasuffix}{}
  %
  \DeclareFontShape{T1}{Alegreya-\alegreyasuffix}{k}{n}{
      <-> \alegreyascale Alegreya-Black-\alegreyainfix-t1
  }{\adjustalegreyaxheight}
  %
  \DeclareFontShape{T1}{Alegreya-\alegreyasuffix}{k}{it}{
      <-> \alegreyascale Alegreya-BlackItalic-\alegreyainfix-t1
  }{\adjustalegreyaxheight\adjustalegreyaslant}
  %
  \DeclareFontShape{T1}{Alegreya-\alegreyasuffix}{k}{sl}{
      <-> ssub * Alegreya-\alegreyasuffix/k/it
  }{\adjustalegreyaxheight\adjustalegreyaslant}
  %
  \DeclareFontShape{T1}{Alegreya-\alegreyasuffix}{b}{n}{
      <-> \alegreyascale Alegreya-Bold-\alegreyainfix-t1
  }{\adjustalegreyaxheight}
  %
  \DeclareFontShape{T1}{Alegreya-\alegreyasuffix}{b}{it}{
      <-> \alegreyascale Alegreya-BoldItalic-\alegreyainfix-t1
  }{\adjustalegreyaxheight\adjustalegreyaslant}
  %
  \DeclareFontShape{T1}{Alegreya-\alegreyasuffix}{b}{sl}{
      <-> ssub * Alegreya-\alegreyasuffix/b/it
  }{\adjustalegreyaxheight\adjustalegreyaslant}
  %
  \DeclareFontShape{T1}{Alegreya-\alegreyasuffix}{m}{n}{
      <-> \alegreyascale Alegreya-Regular-\alegreyainfix-t1
  }{\adjustalegreyaxheight}
  %
  \DeclareFontShape{T1}{Alegreya-\alegreyasuffix}{m}{it}{
      <-> \alegreyascale Alegreya-Italic-\alegreyainfix-t1
  }{\adjustalegreyaxheight\adjustalegreyaslant}
  %
  \DeclareFontShape{T1}{Alegreya-\alegreyasuffix}{m}{sl}{
      <-> ssub * Alegreya-\alegreyasuffix/m/it
  }{\adjustalegreyaxheight\adjustalegreyaslant}
  %
  \DeclareFontShape{T1}{Alegreya-\alegreyasuffix}{bx}{sl}{
      <-> ssub * Alegreya-\alegreyasuffix/b/sl
  }{\adjustalegreyaxheight\adjustalegreyaslant}
  %
  \DeclareFontShape{T1}{Alegreya-\alegreyasuffix}{bx}{n}{
      <-> ssub * Alegreya-\alegreyasuffix/b/n
  }{\adjustalegreyaxheight}
  %
  \DeclareFontShape{T1}{Alegreya-\alegreyasuffix}{bx}{it}{
      <-> ssub * Alegreya-\alegreyasuffix/b/it
  }{\adjustalegreyaxheight\adjustalegreyaslant}
}
% execute the above for all four combinations
\adjustallalegreyafamilies{LF}{lf}
\adjustallalegreyafamilies{OsF}{osf}
\adjustallalegreyafamilies{TLF}{tlf}
\adjustallalegreyafamilies{TOsF}{tosf}
\endgroup
%%%%% HACK ENDS
%%%% now you can load the Alegreya package with the desired options
\usepackage[osf]{Alegreya}

\begin{document}

0123456789{\bfseries 0123456789}{\itshape 0123}{\slshape 0123}

Normal text. \emph{Emphasized text.} \emph{Emphasized text including \emph{emphasized} text.}


The x-height: \expandafter\texttt\expandafter{\the\fontdimen5\font}

The height of `x': \expandafter\texttt\expandafter{\the\fontcharht\font`x}

Rodion \^{S}edrin

\u{U}ladz\`{i}m\`{i}r Damarackij

V\^{a}\v{c}\`{e}sla\u{u} Kuzn\^{a}co\u{u} 

\footnotesize

The x-height: \expandafter\texttt\expandafter{\the\fontdimen5\font}

The height of `x': \expandafter\texttt\expandafter{\the\fontcharht\font`x}

Rodion \^{S}edrin

\u{U}ladz\`{i}m\`{i}r Damarackij

V\^{a}\v{c}\`{e}sla\u{u} Kuzn\^{a}co\u{u} 

\end{document}

答案2

这很奇怪,字体指标中似乎有些奇怪,即使对于明显倾斜的斜体字体,fontdimen1(字体倾斜度)也设置为 0,因此\emph无法将其识别为倾斜字体。您可以将其设置为:

在此处输入图片描述

\documentclass{book}
\usepackage{Alegreya}
\begin{document}

{\itshape \fontdimen1\font=.25pt}


Normal text. \emph{Emphasized text.} \emph{Emphasized text including \emph{emphasized} text.}
\end{document}

相关内容