2

I'm working with an automated system that injects some code that redefines the paragraph command:

% Redefines (sub)paragraphs to behave more like sections
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi

I'm stuck with this change.

This causes issues with some LaTeX packages that I use below these lines.

Is there a simple way to un-do this action? Maybe

\renewcommand{\paragraph}{\oldparagraph}
  • \let\paragraph\oldparagraph and \let\subparagraph\oldsubparagraph... But you shoud check if \oldparagraph and \oldsubparagraph are already defined like in the code above: \ifx\oldparagraph\undefined\else\let\paragraph\oldparagraph\fi and the same for \subparagraph – koleygr Feb 18 at 16:53
1

Doing \renewcommand{\paragraph}{\oldparagraph} will do if \paragraph is defined to begin with.

Better is

\let\paragraph\oldparagraph

In case \oldparagraph is not defined, then your class doesn't allow \paragraph to begin with and you will get an error just like you'd get without the injected code.

By the way, that code is wrong and it should have

\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}\par}

otherwise input such as

\paragraph{Title}
Something

will not have “Something” on a new line (but on the same line with a spurious space in addition) which is almost certainly what the redefinition is aiming to attain.

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.