5

I would like to have two versions of my document. The differences depend on whether kpfonts is loaded or not. If it's not loaded I want to disable the\lettrine command and the arguments in the command should appear as normal text. Below is a 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}

Is there a way of doing this so I wouldn't have to edit the actual text?

4

Adding \renewcommand{\lettrine}[3][]{#2#3} should do.

\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}
  • Worked great, you forgot the [] in the code. You can accept an answer in 9 minutes :) – pythonista Apr 17 '13 at 0:12
  • @AbdulhaqElhouderi Sorry for the mistake. Fixed. – egreg Apr 17 '13 at 0:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.