考虑以下代码:
\documentclass{book}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{pgothic}
\newcommand\titleshading[3]{
\newcommand\xoffset{0.3}
\newcommand\yoffset{-0.25}
% Blur
\foreach \x in {-0.1,0.1} {
\foreach \y in {-0.1,0.1} {
\node[red!30] at (#1em+\xoffset em+\x em,#2em+\yoffset em+\y em) {
\scalebox{3.25}{\Huge\pgothfamily{#3}}
};
}
}
% Main Shadow
\node[red!30] at (#1em+0.3em,#2em-0.2em) {
\scalebox{3.25}{\Huge\pgothfamily{#3}}
};
\node at (#1em,#2em) {
\scalebox{3.25}{\Huge\pgothfamily{#3}}
};
}
\begin{document}
\begin{tikzpicture}[remember picture,overlay]
\titleshading{18}{0}{Ye Olde English} \vspace*{35pt}
% \titleshading{18}{0}{Steak \& Kidney Pies}
\end{tikzpicture}
\end{document}
输出结果如下:
我希望能够通过在下面添加“牛排和腰子派”来完成标题。
但是,当我取消% \titleshading{18}{0}{Steak \& Kidney Pies}
代码中的注释并运行它时,我收到错误。
此外,我想过制作一个长标题:“Ye Olde English Steak & Kidney Pies”,并让 LaTeX 确定从哪里开始新行---但是没有;在这种环境下既不这样做\linebreak
也不工作。\\
tikzpicture
唉,我想,也许,我会创建一个\newcommand
而不是\titleshading
,比如说,\titleshading1
——但这是不允许的。
问题:(i)我该如何完成上述标题,以便“Steak & Kidney Pies”位于“Ye Olde English”下方的中心?(ii)我该如何为文档中可能具有不同字体、缩放比例和阴影的其他标题创建其他标题阴影命令(例如“Ye Olde Stratford-upon-Avon On-the-Street Fish & Chips”使用 Cabin 字体,所有节点缩放 2.5,并具有以前的颜色阴影)?
谢谢。
答案1
问题 #1. 添加垂直偏移,使每次通过时增加相同的量。(yoffsetplus
)
\titleshadingx
问题 #2。类似于使用其他字体和缩放的新命令\titleshading
。阴影略有修正。
这是完整的代码。
% !TeX TS-program = pdflatex
\documentclass[oneside]{book}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{pgothic}
\usepackage[T1]{fontenc}
\newcommand\xoffset{0.3}
\newcommand\yoffset{-0.25}
\newcounter{yoffsetplus}% added <<<<<<<<<<<<<<<<
\setcounter{yoffsetplus}{0}
\newcounter{yoffsetplusx}% added <<<<<<<<<<<<<<<<
\setcounter{yoffsetplusx}{0}
\newcommand\titleshading[3]{%
% Blur
\foreach \x in {-0.1,0.1} {%
\foreach \y in {-0.1,0.1} { %
\node[red!30] at (#1em+\xoffset em+\x em,#2em+\yoffset em+\y em+\theyoffsetplus) {% changed <<<
\scalebox{3.25}{\Huge\pgothfamily{#3}}
};
}
}
% Main Shadow
\node[red!30] at (#1em+0.3em,#2em-0.2em+\theyoffsetplus) {
\scalebox{3.25}{\Huge\pgothfamily{#3}}
};
\node at (#1em,#2em+\theyoffsetplus) {
\scalebox{3.25}{\Huge\pgothfamily{#3}}
};
\addtocounter{yoffsetplus}{-120} % added <<<<<<<<<<<<<<<<<<<<<<
}
\newcommand\titleshadingx[3]{% added <<<<<<<<<<<<<<<<<<<<
% Blur
\foreach \x in {-0.1,0.1} {%
\foreach \y in {-0.1,0.1} {%
\node[red!30] at (#1em+\xoffset em+\x em,#2em+\yoffset em+\y em+\theyoffsetplusx) {%
\scalebox{2.5}{\fontfamily{Cabin-TLF}\fontsize{18}{20}\selectfont #3}
};
}
}
% Main Shadow
\node[red!30] at (#1em+0.3em,#2em-0.2em+\theyoffsetplusx) {%
\scalebox{2.5}{\fontfamily{Cabin-TLF}\fontsize{18}{20}\selectfont #3}
};
\node at (#1em+0.2em,#2em-0.2em+\theyoffsetplusx) {%
\scalebox{2.5}{\fontfamily{Cabin-TLF}\fontsize{18}{20}\selectfont #3}
};
\addtocounter{yoffsetplusx}{-80} % added <<<<<<<<<<<<<<<<<<<<<<
}
\begin{document}
\pagestyle{empty}\parindent0pt
\begin{tikzpicture}[remember picture,overlay]
\titleshading{18}{0}{Ye Olde English}
\titleshading{18}{0}{Steak \& Kidney Pies}
\titleshading{18}{0}{Beer \& Wine}
\end{tikzpicture}
\clearpage
\begin{tikzpicture}[remember picture,overlay]
\titleshadingx{18}{0}{Ye Olde Stratford-upon-Avon}
\titleshadingx{18}{0}{On-the-Street Fish \& Chips}
\titleshadingx{18}{0}{Beer \& Wine}
\end{tikzpicture}
\end{document}
选项
注释掉 \addtocounter{yoffsetplusx}{-80}
%\addtocounter{yoffsetplusx}{-80} % added <<<<<<<<<<<<<<<<<<<<<<
可以使用第二个参数(em 单位)逐个控制垂直间距。
\begin{tikzpicture}[remember picture,overlay]
\titleshadingx{18}{0}{Ye Olde Stratford-upon-Avon}
\titleshadingx{18}{-8}{On-the-Street Fish \& Chips}
\titleshadingx{18}{-20}{Beer \& Wine}
\end{tikzpicture}