此问题已修改。请参阅下文。
我希望能够偶尔将字母变为斜体。
我知道如何将 lettrine 字体改为斜体,但对我来说不幸的是,它提供了一个全局解决方案。
我目前正在处理一份包含许多字母的文档,并且只想将其中一个字母斜体化。如果全部类似的字母则用斜体表示。
请考虑以下 MWE:
\documentclass[12pt]{book}
\usepackage{amsthm,latexsym,amssymb,amsmath,verbatim}
\hoffset 10pt \voffset -45pt
\oddsidemargin 12pt \evensidemargin 10pt \topmargin 35pt
\headheight 25pt \textheight 8in \textwidth 6in
\headsep 55pt \marginparwidth 35pt
\usepackage{lettrine}
\usepackage{xcolor}
\usepackage{verse,anyfontsize}
%% SUBROUTINE TO BE ABLE TO USE BOTH VERSE AND LETTRINES
%% And needed for this MWE so that the lettrine is reasonably large and rises above the adjoined statement.
\def\startverse#1#2{%
\begin{minipage}{4in}%
\firstline#1\relax%
\def\verselineB{#2}%
\if Q\versalletter\def\descstrut{\strut}\else\def\descstrut{}\fi%
\def\Versal{\textcolor{RoyalRed}{%
\scalerel*{$\fontsize{28}{30}\selectfont\versalletter$}%
{\def\stacktype{L}\stackon{T\descstrut}{T}}}}%
\setbox0=\hbox{\Versal\,}%
% \def\leftoffset{-15pt}%WHAT OP ASKED FOR, BUT NOT BEST, IMHO
\def\leftoffset{-.3\wd0}%
\hspace*{\wd0}\hspace{\leftoffset}%
\verselineA\\%
\hspace*{\wd0}\hspace{\leftoffset}%
\llap{\smash{\box0}}%
\verselineB\strut%
\end{minipage}%
}
\def\firstline#1#2\relax{\def\versalletter{#1}\def\verselineA{#2}}
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
\begin{document}
\Large
\lettrine[lines=2,lhang=.0,loversize=0.35,findent=0pt]{\color{red}{\textbf{L}}}{\textbf{\color{red}\textit{ettrine to be italicized}}} \\
\textit{\lettrine[lines=2,lhang=.0,loversize=0.35,findent=0pt]{\color{red}{\textbf{L}}}{\textbf{\color{red}\textit{ettrine italicized}}} } \\
\vskip 15pt
And when I try to push the statement to the right with either an $hskip$, $hspace$, or $hspace*$, nothing happens---although any of these would work in unitalicized case.
\hskip 25pt \hspace{25pt} \hspace*{25pt} \textit{\lettrine[lines=2,lhang=.0,loversize=0.35,findent=0pt]{\color{red}{\textbf{L}}}{\textbf{\color{red}\textit{ettrine italicized}}} }
\end{document}
输出
虽然我能够将字母斜体化,但由于某种我不知道的原因,它会将包含斜体字母的语句向左移动很远,并且我无法使用 、 或 命令强制将其\hskip
移\hspace
回\hspace*
。
(原文)问题:(i)有没有更好的方法一次性将斜体字母(以及通常以小写字母显示的其他内容)变为斜体字母?(ii)是什么原因导致上面的斜体字母一直位于左侧?(iii)由于缺乏更好的方法,我现在如何强制将其恢复到非斜体字母的位置?
更新信息自从发布原始问题以来,我注意到我忘记添加任何额外的句子来配合我的斜体字母。这样做之后,我发现在规定的跳过次数之后,所述字母无法使文本左对齐。通常,我认为最好删除该问题并发布一个新问题。但是,已经提供了一个答案(对于原始提出的问题是正确的)---所以我不能删除这个。对于造成的混乱,我深表歉意,但另一种方法是发布一些修改后的代码和输出,并重新表述问题。请参阅更新的问题。
修订的 MWE
\documentclass[12pt]{book}
\usepackage{amsthm,latexsym,amssymb,amsmath,verbatim}
\hoffset 10pt \voffset -45pt
\oddsidemargin 12pt \evensidemargin 10pt \topmargin 35pt
\headheight 25pt \textheight 8in \textwidth 6in
\headsep 55pt \marginparwidth 35pt
\usepackage{lettrine}
\usepackage{xcolor}
\usepackage{verse,anyfontsize}
%% SUBROUTINE TO BE ABLE TO USE BOTH VERSE AND LETTRINES
%% And needed for this MWE so that the lettrine is reasonably large and rises above the adjoined statement.
\def\startverse#1#2{%
\begin{minipage}{4in}%
\firstline#1\relax%
\def\verselineB{#2}%
\if Q\versalletter\def\descstrut{\strut}\else\def\descstrut{}\fi%
\def\Versal{\textcolor{RoyalRed}{%
\scalerel*{$\fontsize{28}{30}\selectfont\versalletter$}%
{\def\stacktype{L}\stackon{T\descstrut}{T}}}}%
\setbox0=\hbox{\Versal\,}%
% \def\leftoffset{-15pt}%WHAT OP ASKED FOR, BUT NOT BEST, IMHO
\def\leftoffset{-.3\wd0}%
\hspace*{\wd0}\hspace{\leftoffset}%
\verselineA\\%
\hspace*{\wd0}\hspace{\leftoffset}%
\llap{\smash{\box0}}%
\verselineB\strut%
\end{minipage}%
}
\def\firstline#1#2\relax{\def\versalletter{#1}\def\verselineA{#2}}
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
\begin{document}
\Large
\lettrine[lines=2,lhang=.0,loversize=0.35,findent=0pt]{\color{red}{\textbf{L}}}{\textbf{\color{red}\textit{ettrine to be italicized}}} A sentence to go along with the lettrine. A sentence to go along with the lettrine. A sentence to go along with the lettrine.\\
\textit{\lettrine[lines=2,lhang=.0,loversize=0.35,findent=0pt]{\color{red}{\textbf{L}}}{\textbf{\color{red}\textit{ettrine italicized}}}} A sentence to go along with the lettrine. A sentence to go along with the lettrine. A sentence to go along with the lettrine. A sentence to go along with the lettrine. A sentence to go along with the lettrine. \\
\vskip 15pt
As you can see, the text is not left-justtified after two lineskips; And, when I try to push the statement to the right with either an $hskip$, $hspace$, or $hspace*$, nothing happens.
\textit{\lettrine[lines=2,lhang=.0,loversize=0.35,findent=0pt]{\color{red}{\textbf{L}}}{\textbf{\color{red}\textit{ettrine italicized}}}} A sentence to go along with the lettrine. A sentence to go along with the lettrine. A sentence to go along with the lettrine. A sentence to go along with the lettrine. A sentence to go along with the lettrine.
\end{document}
修订后的输出
修改后的问题:我怎样才能将一个字母斜体化(一次),以免发生上述不良事件?
谢谢。
答案1
正如我所评论的,不要\lettrine
在里面包装\textit
...相反的做法...将其放在\textit
lettrine 参数里面。
\documentclass[12pt]{book}
\usepackage{amsthm,latexsym,amssymb,amsmath,verbatim}
\hoffset 10pt \voffset -45pt
\oddsidemargin 12pt \evensidemargin 10pt \topmargin 35pt
\headheight 25pt \textheight 8in \textwidth 6in
\headsep 55pt \marginparwidth 35pt
\usepackage{lettrine}
\usepackage{xcolor}
\usepackage{verse,anyfontsize}
%% SUBROUTINE TO BE ABLE TO USE BOTH VERSE AND LETTRINES
%% And needed for this MWE so that the lettrine is reasonably large and rises above the adjoined statement.
\def\startverse#1#2{%
\begin{minipage}{4in}%
\firstline#1\relax%
\def\verselineB{#2}%
\if Q\versalletter\def\descstrut{\strut}\else\def\descstrut{}\fi%
\def\Versal{\textcolor{RoyalRed}{%
\scalerel*{$\fontsize{28}{30}\selectfont\versalletter$}%
{\def\stacktype{L}\stackon{T\descstrut}{T}}}}%
\setbox0=\hbox{\Versal\,}%
% \def\leftoffset{-15pt}%WHAT OP ASKED FOR, BUT NOT BEST, IMHO
\def\leftoffset{-.3\wd0}%
\hspace*{\wd0}\hspace{\leftoffset}%
\verselineA\\%
\hspace*{\wd0}\hspace{\leftoffset}%
\llap{\smash{\box0}}%
\verselineB\strut%
\end{minipage}%
}
\def\firstline#1#2\relax{\def\versalletter{#1}\def\verselineA{#2}}
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
\begin{document}
\Large
\lettrine[lines=2,lhang=.0,loversize=0.35,findent=0pt]{\color{red}{\textbf{L}}}{\textbf{\color{red}\textit{ettrine to be italicized}}} \\
\lettrine[lines=2,lhang=.0,loversize=0.35,findent=0pt]{\textit{\color{red}{\textbf{L}}}}{\textbf{\color{red}\textit{ettrine italicized}}} \\
\vskip 15pt
And when I try to push the statement to the right with either an $hskip$, $hspace$, or $hspace*$, nothing happens---although any of these would work in unitalicized case.
\hskip 25pt \hspace{25pt} \hspace*{25pt} \lettrine[lines=2,lhang=.0,loversize=0.35,findent=0pt]{\textit{\color{red}{\textbf{L}}}}{\textbf{\color{red}\textit{ettrine italicized}}}
\end{document}
答案2
尝试(更简单的方法)
\lettrine[lines=2,lhang=.0,loversize=0.35,findent=0pt]{\bfseries\color{red}\itshape L}{\bfseries\color{red}\itshape ettrine italicized shifted}
您可能需要使用findent=2pt
来处理斜体T
。
和
\newcommand{\ilettrine}[2]{%
\lettrine[lines=2,lhang=.0,loversize=0.35,findent=0pt]{\color{blue}\bfseries\itshape#1}{\color{blue}\bfseries\itshape#2}
}
并使用 \ilettrine{L}{orem ipsum dolor sit amet}
更新(对较长的文本使用相同的代码)
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
\newcommand{\ilettrine}[2]{%
\lettrine[lines=2,lhang=.0,loversize=0.35,findent=0pt]{\bfseries\color{red}\itshape#1}{\bfseries\color{red}\itshape#2}
}
\begin{document}
\Large
\ilettrine{L}{ettrine to be italicized}A sentence to go along with the lettrine. A sentence to go along with the lettrine. A sentence to go along with the lettrine.\\
\ilettrine{L}{ettrine to be italicized}A sentence to go along with the lettrine. A sentence to go along with the lettrine. A sentence to go along with the lettrine. A sentence to go along with the lettrine. A sentence to go along with the lettrine. \\
\end{document}