LaTeX forum ⇒ GeneralRenaming \newcommand args from #1 to a variable name

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

Renaming \newcommand args from #1 to a variable name

Postby eggmanneo » Fri Mar 07, 2014 10:36 pm

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

  1. \newcommand{\mvncdf}[3]{
  2. \Phi_{#1}\left(#2\middle|#3\right)
  3. }


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?

Tags:

User avatar
cgnieder
Site Moderator
Posts: 1974
Joined: Sat Apr 16, 2011 7:27 pm
Location: Germany
Contact:

Postby cgnieder » Sat Mar 08, 2014 10:23 pm

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
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm
Location: 's-Hertogenbosch, Netherlands

Postby hugovdberg » Sat Mar 08, 2014 10:53 pm

I think I understand what you're after: using named variables in the macro definition like
  1. \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: 1974
Joined: Sat Apr 16, 2011 7:27 pm
Location: Germany
Contact:

Postby cgnieder » Sat Mar 08, 2014 11:31 pm

hugovdberg wrote:I think I understand what you're after: using named variables in the macro definition like
  1. \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
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim


Return to “General”

Who is online

Users browsing this forum: Bing [Bot] and 4 guests