GeneralRenaming \newcommand args from #1 to a variable name

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
eggmanneo
Posts: 10
Joined: Wed Apr 21, 2010 9:03 pm

Renaming \newcommand args from #1 to a variable name

Post by eggmanneo »

I was wondering if there was a way to replace the name of arguments in \newcommand from #1 to another variable name. For exmple, I have this latex code to write the multivariate normal CDF

Code: Select all

\newcommand{\mvncdf}[3]{
\Phi_{#1}\left(#2\middle|#3\right)
}  
I would like to replace the #1, #2, and #3 names of the arguments to somethis else, like naming #1 "n" and #3 "\Sigma". Is there a way to do this?

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
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Renaming \newcommand args from #1 to a variable name

Post by cgnieder »

I'm afraid I don't quite understand what you mean... can you add an example code that shows how you would like to use newcommand?

Regards
site moderator & package author
hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm

Renaming \newcommand args from #1 to a variable name

Post by hugovdberg »

I think I understand what you're after: using named variables in the macro definition like

Code: Select all

\newcommand{foo}[bar]{#bar}
But as far as I know that's not possible, and I'm not sure why you should want it. Unless you're after optional arguments with key/value pairs, like in this post on tex.sx.
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Renaming \newcommand args from #1 to a variable name

Post by cgnieder »

hugovdberg wrote:I think I understand what you're after: using named variables in the macro definition like

Code: Select all

\newcommand{foo}[bar]{#bar}
But as far as I know that's not possible, and I'm not sure why you should want it.
If that is the goal: this is indeed impossible.

Regards
site moderator & package author
Post Reply