我希望我的文档有两个版本。区别取决于是否kpfonts
加载。如果未加载,我想禁用该\lettrine
命令,并且命令中的参数应显示为普通文本。下面是 MWE。
\documentclass{scrreprt}
\usepackage{lettrine}
\usepackage{lipsum}
%\usepackage{kpfonts}
\makeatletter
\@ifpackageloaded{kpfonts}{%
%don't do anything in this MWE
}
{
\renewcommand{\familydefault}{\sfdefault} %just an example
%I also want to disable lettrine here
}
\makeatother
\begin{document}
\chapter{Whatever}
\lettrine[findent=1pt, nindent=1pt]{N}{ow, let lipsum do the job:} \lipsum[1]
%Now, let lipsum do the job: \lipsum[1]. <<Achieve this with the above line
\end{document}
有没有办法做到这一点,让我不必编辑实际的文本?
答案1
添加\renewcommand{\lettrine}[3][]{#2#3}
就可以了。
\documentclass{scrreprt}
\usepackage{lettrine}
\usepackage{lipsum}
%\usepackage{kpfonts}
\makeatletter
\@ifpackageloaded{kpfonts}
{%
%don't do anything in this MWE
}
{%
\renewcommand{\familydefault}{\sfdefault}%just an example
\renewcommand{\lettrine}[3][]{#2#3}%
}
\makeatother
\begin{document}
\chapter{Whatever}
\lettrine[findent=1pt, nindent=1pt]{N}{ow, let lipsum do the job:} \lipsum[1]
Now, let lipsum do the job: \lipsum[1].
\end{document}