考虑以下代码:
\documentclass[a5paper,12pt,onecolumn,openany,final]{book}
\usepackage[hmargin=0.7in,vmargin=0.75in]{geometry}
\usepackage{pstricks,psvectorian}
\usepackage{color}
\usepackage{scalefnt,scalerel}
\definecolor{Gold}{RGB}{228,168,73}
\definecolor{BrooklynBlue}{RGB}{33,41,88}
\newcommand{\mytitle}[1]% #1 = title
{\bgroup
\Huge
\sbox0{\parbox{\columnwidth}{\centering\textbf{\color{black}#1}}}%
\sbox1{\parbox{\columnwidth}{\centering\textbf{\color{Gold}#1}}}%
\usebox0\llap{\raisebox{1.37pt}{\usebox1}}
\egroup}
% % % Compiled with Xelatex
\begin{document}
\thispagestyle{empty}
\begin{pspicture}(-5,0)(5,5)%
\renewcommand*{\psvectorianDefaultColor}{BrooklynBlue}%
\psframe[fillcolor=BrooklynBlue,fillstyle=solid](-5,0)(5,5) %Used with colored frame
\psframe[linecolor=BrooklynBlue](-5,0)(5,5)% draws frame in black.
%top and bottom center
\rput[tc](0,2.5){\mytitle{\selectfont\scalefont{0.8}{ \vstretch{1.2}{No Hay Caf{\'{e}} en el Men{\'{u}}}}}}
%\rput[tc](0,2.5){\mytitle{\selectfont\scalefont{0.8}{ \vstretch{1.2}{\textbf{No Hay Caf{\'{e}} en el Men{\'{u}}}}}}}
\end{pspicture}%
\end{document}
产生(带有错误):
但是,当我注释掉它\rput[tc](0,2.5){\mytitle{\selectfont\scalefont{0.8}{ \vstretch{1.2}{No Hay Caf{\'{e}} en el Men{\'{u}}}}}}
并用 --- 替换它时\rput[tc](0,2.5){\mytitle{\selectfont\scalefont{0.8}{ \vstretch{1.2}{\textbf{No Hay Caf{\'{e}} en el Men{\'{u}}}}}}}
,一切似乎都运行良好:
问题:为什么 Latex 认为原始标题处于数学模式(我该怎么办)?然后,当我简单地插入命令时\textbf
,一切似乎都很好?我用 编译代码xelatex
。
谢谢。
答案1
手册scalerel
告诉您\vstretch
在数学模式下排版其参数。
但你需要scalerel
从这里开始吗?
\documentclass[a5paper,12pt,onecolumn,openany,final]{book}
\usepackage[hmargin=0.7in,vmargin=0.75in]{geometry}
\usepackage{graphicx,pstricks,psvectorian}
\usepackage{color}
\definecolor{Gold}{RGB}{228,168,73}
\definecolor{BrooklynBlue}{RGB}{33,41,88}
\newcommand{\scaletitle}[2]{%
\scalebox{0.8}[1.2]{\textcolor{#1}{\Huge\bfseries#2}}%
}
\newcommand{\mytitle}[1]{%
\rlap{\parbox{\columnwidth}{\centering\scaletitle{black}{#1}}}%
\raisebox{1.37pt}{\parbox{\columnwidth}{\centering\scaletitle{Gold}{#1}}}%
}
% % % Compiled with Xelatex
\begin{document}
\thispagestyle{empty}
\begin{pspicture}(-5,0)(5,5)%
\renewcommand*{\psvectorianDefaultColor}{BrooklynBlue}
\psframe[fillcolor=BrooklynBlue,fillstyle=solid](-5,0)(5,5)% Used with colored frame
\psframe[linecolor=BrooklynBlue](-5,0)(5,5)% draws frame in black.
%top and bottom center
\rput[tc](0,2.5){\mytitle{No Hay Caf\'{e} en el Men\'{u}}}
\end{pspicture}
\end{document}
Caf{\'{e}}
是错误的(除非你处理的是 bib 文件中的文本)- 使用单独的函数来处理各种设置会更好
- 不需要
\sbox
- 编译
xelatex-unsafe