0

I've been trying to write a command to display a partial derivative with as follow

partial derivative of f by x

I've written this :

\documentclass[11pt, french]{article}
\usepackage[french]{babel}
\selectlanguage{french}
\usepackage[T1]{fontenc}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{esint}
\begin{document}
\newcommand{\par}[2]{\frac{\partial #1}{\partial #2}}
\par{f}{x}
\end{document}

But it doesn't work...

3
  • Unrelated but never use \usepackage[T1]{fontenc} with xelatex, it removed unicode support forcing 8bit fonts and inncorrect hyphenation Oct 24, 2022 at 13:44
  • \par is already defined. Use a different name. Oct 24, 2022 at 13:45
  • Thank you for you answers! It works! :)
    – Azagal258
    Oct 24, 2022 at 13:55

1 Answer 1

0

\par is a tex primitive that ends a paragraph. You might expect

! LaTeX Error: Command \par already defined.
               Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.9 ...{\par}[2]{\frac{\partial #1}{\partial #2}}
                                                  
? 

But actually you get

Runaway argument?
{
! Paragraph ended before \new@command was complete.
<to be read again> 
                   \par 
l.9 \newcommand{\par
                    }[2]{\frac{\partial #1}{\partial #2}}
?

Due to the special nature of \par.

Simply call the command something else, such as \pardiff, and use in math mode:

\documentclass[11pt, french]{article}
\usepackage[french]{babel}
\selectlanguage{french}
% xetex \usepackage[T1]{fontenc}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{esint}
\begin{document}
\newcommand{\pardiff}[2]{\frac{\partial #1}{\partial #2}}
$\pardiff{f}{x}$
\end{document}

enter image description here

8
  • Thank you for you answer! It works! :)
    – Azagal258
    Oct 24, 2022 at 13:55
  • Unfortunately, \par is no TeX primitive in new LaTeX. It is a macro which allows hooks. Things are more and more complicated. On the other hand, \par is TeX primitive in OpTeX and user can re-define it without any change of basic behavior, because OpTeX uses \_par internally. All control sequences without _ are designed in "user naming space". Thus: if @Azagal258 used OpTeX then no problem would be after \def\par{...}.
    – wipet
    Oct 24, 2022 at 17:47
  • @wipet \par has been non-primitve (at times) in latex since the start, it is the case more often now, but as you know the error here is unrelated to the definition of \par it is a primitive property of the cstoken with name par whatver its definition. Oct 24, 2022 at 17:50
  • @wipet are you saying you also stop a blank line returning \par? I doubt the OP wants blank lines to generate partial derivative fractions Oct 24, 2022 at 17:53
  • @wipet ah you do, nice:-) luatex.... :-) Oct 24, 2022 at 17:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .