Can you create concatenate variable names in LaTex? [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite
1













This question already has an answer here:



  • Using command parameters to use another command

    3 answers



I would like to create variables to hold strings like f(x)=3x+1 to be inputted into an exam questions.



I can create variables like funA, funB, … et cetera. The problem is how do I reference them using A, B, … et cetera.



documentclass[12pt]exam

% conditional statements
usepackagexifthen

newcommandexamA

newcommandfunA$s(t) = 12t^2 -7t + 16$
newcommandfunB$s(t) = 16t^2 +3t + 10$
newcommandfunC$s(t) = 12t^2 + t + 10.$

begindocument

beginquestions

question % I would like funexam to return funA when exam = a. Sadly it doesn't

The position of an object moving along a straight line is given by funexam. Find the average velocity of the object over the interval $[1,1+h]$ where $h>0$ is a real number.

question % this works but is a lot to write when accommodating 10 stored functions

ifthenelseequalexamA

newcommandfunction$s(t) = 12t^2 -7t + 16.$


ifthenelseequalexamB

newcommandfunction$s(t) = 16t^2 +3t + 10.$


newcommandfunction$s(t) = 12t^2 + t + 10.$



The position of an object moving along a straight line is given by function Find the average velocity of the object over the interval $[1,1+h]$ where $h>0$ is a real number.

endquestions
enddocument









share|improve this question















marked as duplicate by Werner, Stefan Pinnow, Troy, Kurt, dexteritas Dec 4 at 20:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • csname funexamendcsname
    – Phelype Oleinik
    Dec 4 at 16:02










  • I added an answer to the duplicate question.
    – egreg
    Dec 4 at 21:11














up vote
4
down vote

favorite
1













This question already has an answer here:



  • Using command parameters to use another command

    3 answers



I would like to create variables to hold strings like f(x)=3x+1 to be inputted into an exam questions.



I can create variables like funA, funB, … et cetera. The problem is how do I reference them using A, B, … et cetera.



documentclass[12pt]exam

% conditional statements
usepackagexifthen

newcommandexamA

newcommandfunA$s(t) = 12t^2 -7t + 16$
newcommandfunB$s(t) = 16t^2 +3t + 10$
newcommandfunC$s(t) = 12t^2 + t + 10.$

begindocument

beginquestions

question % I would like funexam to return funA when exam = a. Sadly it doesn't

The position of an object moving along a straight line is given by funexam. Find the average velocity of the object over the interval $[1,1+h]$ where $h>0$ is a real number.

question % this works but is a lot to write when accommodating 10 stored functions

ifthenelseequalexamA

newcommandfunction$s(t) = 12t^2 -7t + 16.$


ifthenelseequalexamB

newcommandfunction$s(t) = 16t^2 +3t + 10.$


newcommandfunction$s(t) = 12t^2 + t + 10.$



The position of an object moving along a straight line is given by function Find the average velocity of the object over the interval $[1,1+h]$ where $h>0$ is a real number.

endquestions
enddocument









share|improve this question















marked as duplicate by Werner, Stefan Pinnow, Troy, Kurt, dexteritas Dec 4 at 20:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • csname funexamendcsname
    – Phelype Oleinik
    Dec 4 at 16:02










  • I added an answer to the duplicate question.
    – egreg
    Dec 4 at 21:11












up vote
4
down vote

favorite
1









up vote
4
down vote

favorite
1






1






This question already has an answer here:



  • Using command parameters to use another command

    3 answers



I would like to create variables to hold strings like f(x)=3x+1 to be inputted into an exam questions.



I can create variables like funA, funB, … et cetera. The problem is how do I reference them using A, B, … et cetera.



documentclass[12pt]exam

% conditional statements
usepackagexifthen

newcommandexamA

newcommandfunA$s(t) = 12t^2 -7t + 16$
newcommandfunB$s(t) = 16t^2 +3t + 10$
newcommandfunC$s(t) = 12t^2 + t + 10.$

begindocument

beginquestions

question % I would like funexam to return funA when exam = a. Sadly it doesn't

The position of an object moving along a straight line is given by funexam. Find the average velocity of the object over the interval $[1,1+h]$ where $h>0$ is a real number.

question % this works but is a lot to write when accommodating 10 stored functions

ifthenelseequalexamA

newcommandfunction$s(t) = 12t^2 -7t + 16.$


ifthenelseequalexamB

newcommandfunction$s(t) = 16t^2 +3t + 10.$


newcommandfunction$s(t) = 12t^2 + t + 10.$



The position of an object moving along a straight line is given by function Find the average velocity of the object over the interval $[1,1+h]$ where $h>0$ is a real number.

endquestions
enddocument









share|improve this question
















This question already has an answer here:



  • Using command parameters to use another command

    3 answers



I would like to create variables to hold strings like f(x)=3x+1 to be inputted into an exam questions.



I can create variables like funA, funB, … et cetera. The problem is how do I reference them using A, B, … et cetera.



documentclass[12pt]exam

% conditional statements
usepackagexifthen

newcommandexamA

newcommandfunA$s(t) = 12t^2 -7t + 16$
newcommandfunB$s(t) = 16t^2 +3t + 10$
newcommandfunC$s(t) = 12t^2 + t + 10.$

begindocument

beginquestions

question % I would like funexam to return funA when exam = a. Sadly it doesn't

The position of an object moving along a straight line is given by funexam. Find the average velocity of the object over the interval $[1,1+h]$ where $h>0$ is a real number.

question % this works but is a lot to write when accommodating 10 stored functions

ifthenelseequalexamA

newcommandfunction$s(t) = 12t^2 -7t + 16.$


ifthenelseequalexamB

newcommandfunction$s(t) = 16t^2 +3t + 10.$


newcommandfunction$s(t) = 12t^2 + t + 10.$



The position of an object moving along a straight line is given by function Find the average velocity of the object over the interval $[1,1+h]$ where $h>0$ is a real number.

endquestions
enddocument




This question already has an answer here:



  • Using command parameters to use another command

    3 answers







variable






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 4 at 16:20









Bernard

164k769192




164k769192










asked Dec 4 at 15:56









Garth Fleming

37218




37218




marked as duplicate by Werner, Stefan Pinnow, Troy, Kurt, dexteritas Dec 4 at 20:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Werner, Stefan Pinnow, Troy, Kurt, dexteritas Dec 4 at 20:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.













  • csname funexamendcsname
    – Phelype Oleinik
    Dec 4 at 16:02










  • I added an answer to the duplicate question.
    – egreg
    Dec 4 at 21:11
















  • csname funexamendcsname
    – Phelype Oleinik
    Dec 4 at 16:02










  • I added an answer to the duplicate question.
    – egreg
    Dec 4 at 21:11















csname funexamendcsname
– Phelype Oleinik
Dec 4 at 16:02




csname funexamendcsname
– Phelype Oleinik
Dec 4 at 16:02












I added an answer to the duplicate question.
– egreg
Dec 4 at 21:11




I added an answer to the duplicate question.
– egreg
Dec 4 at 21:11










1 Answer
1






active

oldest

votes

















up vote
4
down vote



accepted










TeX allows you to reference control sequence names using a csname...endcsname pair. Any command inside this csname...endcsname pair will be expanded (i.e.: replaced by its meaning) until only unexpandable tokens are left, then TeX creates a control sequence out of the contents passed to csname...endcsname.



For instance, if you have newcommandexamA, then csname funAendcsname and csname funexamendcsname will both expand to funA. You can create a wrapper command to avoid writing csname...endcsname every single time:



documentclass[12pt]exam

newcommandexamA

newcommandfun[1]csname fun#1endcsname
% or:
% newcommandfuncsname funexamendcsname, then use just fun instead of funexam
newcommandfunA$s(t) = 12t^2 -7t + 16$
newcommandfunB$s(t) = 16t^2 +3t + 10$
newcommandfunC$s(t) = 12t^2 + t + 10$

begindocument

beginquestions

question

The position of an object moving along a straight line is given by funexam. Find the average velocity of the object over the interval $[1,1+h]$ where $h>0$ is a real number.

endquestions
enddocument





share|improve this answer




















  • LaTeX has @nameuse but unfortunately it has a @ in its name...
    – jfbu
    Dec 4 at 16:21










  • @jfbu And there's expl3's use:c too, but if you tilt your head to the left it looks too sad ;)
    – Phelype Oleinik
    Dec 4 at 16:24











  • @jfbu and @PhelypeOleinik: And etoolbox's csuse, if we're compiling a list :).
    – Circumscribe
    Dec 4 at 16:34











  • @Circumscribe good point!
    – jfbu
    Dec 4 at 16:37










  • @PhelypeOleinik you can tilt to your right :)
    – jfbu
    Dec 4 at 16:38

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
4
down vote



accepted










TeX allows you to reference control sequence names using a csname...endcsname pair. Any command inside this csname...endcsname pair will be expanded (i.e.: replaced by its meaning) until only unexpandable tokens are left, then TeX creates a control sequence out of the contents passed to csname...endcsname.



For instance, if you have newcommandexamA, then csname funAendcsname and csname funexamendcsname will both expand to funA. You can create a wrapper command to avoid writing csname...endcsname every single time:



documentclass[12pt]exam

newcommandexamA

newcommandfun[1]csname fun#1endcsname
% or:
% newcommandfuncsname funexamendcsname, then use just fun instead of funexam
newcommandfunA$s(t) = 12t^2 -7t + 16$
newcommandfunB$s(t) = 16t^2 +3t + 10$
newcommandfunC$s(t) = 12t^2 + t + 10$

begindocument

beginquestions

question

The position of an object moving along a straight line is given by funexam. Find the average velocity of the object over the interval $[1,1+h]$ where $h>0$ is a real number.

endquestions
enddocument





share|improve this answer




















  • LaTeX has @nameuse but unfortunately it has a @ in its name...
    – jfbu
    Dec 4 at 16:21










  • @jfbu And there's expl3's use:c too, but if you tilt your head to the left it looks too sad ;)
    – Phelype Oleinik
    Dec 4 at 16:24











  • @jfbu and @PhelypeOleinik: And etoolbox's csuse, if we're compiling a list :).
    – Circumscribe
    Dec 4 at 16:34











  • @Circumscribe good point!
    – jfbu
    Dec 4 at 16:37










  • @PhelypeOleinik you can tilt to your right :)
    – jfbu
    Dec 4 at 16:38














up vote
4
down vote



accepted










TeX allows you to reference control sequence names using a csname...endcsname pair. Any command inside this csname...endcsname pair will be expanded (i.e.: replaced by its meaning) until only unexpandable tokens are left, then TeX creates a control sequence out of the contents passed to csname...endcsname.



For instance, if you have newcommandexamA, then csname funAendcsname and csname funexamendcsname will both expand to funA. You can create a wrapper command to avoid writing csname...endcsname every single time:



documentclass[12pt]exam

newcommandexamA

newcommandfun[1]csname fun#1endcsname
% or:
% newcommandfuncsname funexamendcsname, then use just fun instead of funexam
newcommandfunA$s(t) = 12t^2 -7t + 16$
newcommandfunB$s(t) = 16t^2 +3t + 10$
newcommandfunC$s(t) = 12t^2 + t + 10$

begindocument

beginquestions

question

The position of an object moving along a straight line is given by funexam. Find the average velocity of the object over the interval $[1,1+h]$ where $h>0$ is a real number.

endquestions
enddocument





share|improve this answer




















  • LaTeX has @nameuse but unfortunately it has a @ in its name...
    – jfbu
    Dec 4 at 16:21










  • @jfbu And there's expl3's use:c too, but if you tilt your head to the left it looks too sad ;)
    – Phelype Oleinik
    Dec 4 at 16:24











  • @jfbu and @PhelypeOleinik: And etoolbox's csuse, if we're compiling a list :).
    – Circumscribe
    Dec 4 at 16:34











  • @Circumscribe good point!
    – jfbu
    Dec 4 at 16:37










  • @PhelypeOleinik you can tilt to your right :)
    – jfbu
    Dec 4 at 16:38












up vote
4
down vote



accepted







up vote
4
down vote



accepted






TeX allows you to reference control sequence names using a csname...endcsname pair. Any command inside this csname...endcsname pair will be expanded (i.e.: replaced by its meaning) until only unexpandable tokens are left, then TeX creates a control sequence out of the contents passed to csname...endcsname.



For instance, if you have newcommandexamA, then csname funAendcsname and csname funexamendcsname will both expand to funA. You can create a wrapper command to avoid writing csname...endcsname every single time:



documentclass[12pt]exam

newcommandexamA

newcommandfun[1]csname fun#1endcsname
% or:
% newcommandfuncsname funexamendcsname, then use just fun instead of funexam
newcommandfunA$s(t) = 12t^2 -7t + 16$
newcommandfunB$s(t) = 16t^2 +3t + 10$
newcommandfunC$s(t) = 12t^2 + t + 10$

begindocument

beginquestions

question

The position of an object moving along a straight line is given by funexam. Find the average velocity of the object over the interval $[1,1+h]$ where $h>0$ is a real number.

endquestions
enddocument





share|improve this answer












TeX allows you to reference control sequence names using a csname...endcsname pair. Any command inside this csname...endcsname pair will be expanded (i.e.: replaced by its meaning) until only unexpandable tokens are left, then TeX creates a control sequence out of the contents passed to csname...endcsname.



For instance, if you have newcommandexamA, then csname funAendcsname and csname funexamendcsname will both expand to funA. You can create a wrapper command to avoid writing csname...endcsname every single time:



documentclass[12pt]exam

newcommandexamA

newcommandfun[1]csname fun#1endcsname
% or:
% newcommandfuncsname funexamendcsname, then use just fun instead of funexam
newcommandfunA$s(t) = 12t^2 -7t + 16$
newcommandfunB$s(t) = 16t^2 +3t + 10$
newcommandfunC$s(t) = 12t^2 + t + 10$

begindocument

beginquestions

question

The position of an object moving along a straight line is given by funexam. Find the average velocity of the object over the interval $[1,1+h]$ where $h>0$ is a real number.

endquestions
enddocument






share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 4 at 16:11









Phelype Oleinik

21.3k54380




21.3k54380











  • LaTeX has @nameuse but unfortunately it has a @ in its name...
    – jfbu
    Dec 4 at 16:21










  • @jfbu And there's expl3's use:c too, but if you tilt your head to the left it looks too sad ;)
    – Phelype Oleinik
    Dec 4 at 16:24











  • @jfbu and @PhelypeOleinik: And etoolbox's csuse, if we're compiling a list :).
    – Circumscribe
    Dec 4 at 16:34











  • @Circumscribe good point!
    – jfbu
    Dec 4 at 16:37










  • @PhelypeOleinik you can tilt to your right :)
    – jfbu
    Dec 4 at 16:38
















  • LaTeX has @nameuse but unfortunately it has a @ in its name...
    – jfbu
    Dec 4 at 16:21










  • @jfbu And there's expl3's use:c too, but if you tilt your head to the left it looks too sad ;)
    – Phelype Oleinik
    Dec 4 at 16:24











  • @jfbu and @PhelypeOleinik: And etoolbox's csuse, if we're compiling a list :).
    – Circumscribe
    Dec 4 at 16:34











  • @Circumscribe good point!
    – jfbu
    Dec 4 at 16:37










  • @PhelypeOleinik you can tilt to your right :)
    – jfbu
    Dec 4 at 16:38















LaTeX has @nameuse but unfortunately it has a @ in its name...
– jfbu
Dec 4 at 16:21




LaTeX has @nameuse but unfortunately it has a @ in its name...
– jfbu
Dec 4 at 16:21












@jfbu And there's expl3's use:c too, but if you tilt your head to the left it looks too sad ;)
– Phelype Oleinik
Dec 4 at 16:24





@jfbu And there's expl3's use:c too, but if you tilt your head to the left it looks too sad ;)
– Phelype Oleinik
Dec 4 at 16:24













@jfbu and @PhelypeOleinik: And etoolbox's csuse, if we're compiling a list :).
– Circumscribe
Dec 4 at 16:34





@jfbu and @PhelypeOleinik: And etoolbox's csuse, if we're compiling a list :).
– Circumscribe
Dec 4 at 16:34













@Circumscribe good point!
– jfbu
Dec 4 at 16:37




@Circumscribe good point!
– jfbu
Dec 4 at 16:37












@PhelypeOleinik you can tilt to your right :)
– jfbu
Dec 4 at 16:38




@PhelypeOleinik you can tilt to your right :)
– jfbu
Dec 4 at 16:38


Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay