Math & ScienceDeclareMathOperator-like commands

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
dandus
Posts: 10
Joined: Thu Mar 31, 2011 12:41 pm

DeclareMathOperator-like commands

Post by dandus »

I want to define commands that work like DeclareMathOperator, allowing to deine other commands in a straightforward way.

E.G., I want to be able to write something like

Code: Select all

\DeclarePartialDerivative{a}{\alpha}
and make it work like

Code: Select all

\newcommand\dea[1]{\frac{\partial #1}{\partial \alpha}}
so that every partial derivative I need is defined as a "\de[something] command."
Any suggestion? I tried to check the file where \DeclareMathOperator is defined (amsopn.sty), but still couldn't understand what to do.

Thankyou in advance!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

DeclareMathOperator-like commands

Post by localghost »

I cannot really comprehend what you expect. But perhaps the esdiff package can be helpful.


Thorsten
dandus
Posts: 10
Joined: Thu Mar 31, 2011 12:41 pm

DeclareMathOperator-like commands

Post by dandus »

I did find that useful, thankyou, though it wasn't what I wanted. I'll try to make myself clearer: Suppose I have a whole lot of derivatives to define in my source code. For example, suppose I want to define partial derivatives with respect to x,y,z,t and \alpha as \dex,\dey,\dez,\det,\dea. Usually, what I'd do is give

Code: Select all

\newcommand\dei[2]{\frac{\partial #1}{\partial #2}}
\newcommand\dex[1]{\dei{#1}x}
\newcommand\dey[1]{\dey{#1}y}
\newcommand\dez[1]{\dez{#1}z}
\newcommand\det[1]{\det{#1}t}
\newcommand\dea[1]{\det{#1]\alpha}
but I want to define a \DeclarePartialDerivative command which defines the same commands, but is written in source as

Code: Select all

\DeclarePartialDerivative{x}{x}
\DeclarePartialDerivative{y}{y}
\DeclarePartialDerivative{z}{z}
\DeclarePartialDerivative{t}{t}
\DeclarePartialDerivative{a}{\alpha}
how could I do?
kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

Re: DeclareMathOperator-like commands

Post by kaiserkarl13 »

You might have a look at the amsmath package and how it defines \DeclareMathOperator. That's a similar idea to what you're trying to do.
dandus
Posts: 10
Joined: Thu Mar 31, 2011 12:41 pm

DeclareMathOperator-like commands

Post by dandus »

kaiserkarl13 wrote:You might have a look at the amsmath package and how it defines \DeclareMathOperator. That's a similar idea to what you're trying to do.
That's what I did, but couldn't figure out how it worked either. That's why I was asking about it.
Post Reply