LaTeX defines several conditional macros, with a syntax very different from the primitive 

\if?&lt;condition&gt;&lt;true&gt;\else&lt;false&gt;\fi


where \if? denotes any of the primitive conditionals. The conditionals defined by LaTeX have the form

\@ifsomething{&lt;arg&gt;}{&lt;true&gt;}{&lt;false&gt;}


or

\@ifsomething{&lt;arg1&gt;}{&lt;arg2&gt;}{&lt;true&gt;}{&lt;false&gt;}


Conditionals of the first kind are \@ifundefined and \@ifpackageloaded; among the second kind are \@ifpackagelater and \@ifpackagewith. The motivation for the distinction is that in the second kind we need something more to check a condition (the package name and an option name, for \@ifpackagewith).

The &lt;true&gt; and &lt;false&gt; code are executed respectively when the condition is satisfied or not. So

\@ifpackageloaded{geometry}
  {\newcommand\qw{\itshape}}
  {\newcommand\qw{\bfseries}}


is the answer. Either argument can be empty, of course.

You find an example of \@ifpackageloaded and some more information in Italian in this book (p. 78 for the main problem)

Note There is also \@ifdefinable&lt;control sequence&gt;{&lt;true&gt;} that has no "false" branch; it will execute the code &lt;true&gt; if the &lt;control sequence&gt; is undefined and raise an error otherwise (ignoring the &lt;true&gt; code).

ifpackageloaded question
I have a maltab model, output of which (from an RL circuit) is a value for current. I want to interpret this value of current into a PWM signal with frequency of 1000Hz and duty cycle of 50%. I have only worked with defined pwm signals with constant frequency &amp; duty cycle. 
so basically the system should be like this:

RL CKT - Current(0.5A) --> PWM signal generator_output = 0.5A @ 1000Hz &amp; 50% Duty Cycle

Thanks for any form of guidance!
