How to define a macro with multiple optional parameters?xparse: Define new command with multiple optional...
How to prepare vegetables for a sandwich that can last for several days in a fridge?
Can the SpaceX Dragon 2 crew vehicle still use the draco and super draco thrusters to slow down when landing?
What is the meaning of "pick up" in this sentence?
Why is c4 a better move in this position?
Connecting top and bottom of adjacent circles
Why is commutativity optional in multiplication for rings?
Metadata API deployments are failing in Spring '19
When does coming up with an idea constitute sufficient contribution for authorship?
LTSpice: When running a linear AC simulation, how to view the voltage ratio between two voltages?
Has the Isbell–Freyd criterion ever been used to check that a category is concretisable?
What happens if a wizard reaches level 20 but has no 3rd-level spells that they can use with the Signature Spells feature?
Is my plan for fixing my water heater leak bad?
How do we edit a novel that's written by several people?
Proof by Induction - New to proofs
Does Windows 10's telemetry include sending *.doc files if Word crashed?
Why do neural networks need so many training examples to perform?
Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?
"Sheng" as a male given name
Could be quantum mechanics necessary to analyze some biology scenarios?
If all harmonics are generated by plucking, how does a guitar string produce a pure frequency sound?
Do any poskim exempt 13-20-year-olds from Mussaf?
Why does the DC-9-80 have this cusp in its fuselage?
Which branches of mathematics can be done just in terms of morphisms and composition?
What do these brackets mean?
How to define a macro with multiple optional parameters?
xparse: Define new command with multiple optional parametersPassing parameters to g@addto@macrodefine a macro with two parameters delimited by optional spacesHow to name arguments in newcommand?Define a new command with parameters inside newcommandCommand calls with multiple parametersChange reference text of label involving macro whose name depends on macrodef macro with multiple parametersnew environment with multiple parametersDefine macro as wrapper for parameters of a command
After I had a macro that worked, I tried to improve it by making some parameters optional.
Unfortunately the macro no longer works. Instead I'm getting errors I do not understand, for example:
LaTeX Warning: Label `{}####5' multiply defined.
! Illegal parameter number in definition of fLab.
The last code I tried looked like this:
%% Graphics figure with caption and label
% [1:placement,] 2:relative width, 3:file name[, 4:caption[, 5:label]]
newcommand{figCapLab}[5][htbp]{%
ifthenelse{equal{#5}{}}%
{renewcommand{fLab}{}}%
{renewcommand{fLab}{label{##5}}}%
ifthenelse{equal{#4}{}}%
{renewcommand{fCap}{fLab}}%
{renewcommand{fCap}{caption{fLab{small{}##4}}}}%
begin{figure}[#1]%
centering%
begin{minipage}[t]{#2textwidth}%
includegraphics[width=textwidth]{#3}% is width of surrounding minipage
fCap%
end{minipage}%
end{figure}
}
%% Graphics figure with caption
% [1:placement,] 2:relative width, 3:file name, 4:caption
newcommand{figCap}[4]{%
ifthenelse{equal{#1}{}}%
{figCapLab{#2}{#3}{#4}{}}%
{figCapLab[#1]{#2}{#3}{#4}{}}%
}
%% Graphics figure with label
% [1:placement,] 2:relative width, 3:file name, 4:label
newcommand{figLab}[4]{%
ifthenelse{equal{#1}{}}%
{figCapLab{#2}{#3}{}{#4}}%
{figCapLab[#1]{#2}{#3}{}{#4}}%
}
Who can explain what went wrong?
macros parameters
New contributor
add a comment |
After I had a macro that worked, I tried to improve it by making some parameters optional.
Unfortunately the macro no longer works. Instead I'm getting errors I do not understand, for example:
LaTeX Warning: Label `{}####5' multiply defined.
! Illegal parameter number in definition of fLab.
The last code I tried looked like this:
%% Graphics figure with caption and label
% [1:placement,] 2:relative width, 3:file name[, 4:caption[, 5:label]]
newcommand{figCapLab}[5][htbp]{%
ifthenelse{equal{#5}{}}%
{renewcommand{fLab}{}}%
{renewcommand{fLab}{label{##5}}}%
ifthenelse{equal{#4}{}}%
{renewcommand{fCap}{fLab}}%
{renewcommand{fCap}{caption{fLab{small{}##4}}}}%
begin{figure}[#1]%
centering%
begin{minipage}[t]{#2textwidth}%
includegraphics[width=textwidth]{#3}% is width of surrounding minipage
fCap%
end{minipage}%
end{figure}
}
%% Graphics figure with caption
% [1:placement,] 2:relative width, 3:file name, 4:caption
newcommand{figCap}[4]{%
ifthenelse{equal{#1}{}}%
{figCapLab{#2}{#3}{#4}{}}%
{figCapLab[#1]{#2}{#3}{#4}{}}%
}
%% Graphics figure with label
% [1:placement,] 2:relative width, 3:file name, 4:label
newcommand{figLab}[4]{%
ifthenelse{equal{#1}{}}%
{figCapLab{#2}{#3}{}{#4}}%
{figCapLab[#1]{#2}{#3}{}{#4}}%
}
Who can explain what went wrong?
macros parameters
New contributor
add a comment |
After I had a macro that worked, I tried to improve it by making some parameters optional.
Unfortunately the macro no longer works. Instead I'm getting errors I do not understand, for example:
LaTeX Warning: Label `{}####5' multiply defined.
! Illegal parameter number in definition of fLab.
The last code I tried looked like this:
%% Graphics figure with caption and label
% [1:placement,] 2:relative width, 3:file name[, 4:caption[, 5:label]]
newcommand{figCapLab}[5][htbp]{%
ifthenelse{equal{#5}{}}%
{renewcommand{fLab}{}}%
{renewcommand{fLab}{label{##5}}}%
ifthenelse{equal{#4}{}}%
{renewcommand{fCap}{fLab}}%
{renewcommand{fCap}{caption{fLab{small{}##4}}}}%
begin{figure}[#1]%
centering%
begin{minipage}[t]{#2textwidth}%
includegraphics[width=textwidth]{#3}% is width of surrounding minipage
fCap%
end{minipage}%
end{figure}
}
%% Graphics figure with caption
% [1:placement,] 2:relative width, 3:file name, 4:caption
newcommand{figCap}[4]{%
ifthenelse{equal{#1}{}}%
{figCapLab{#2}{#3}{#4}{}}%
{figCapLab[#1]{#2}{#3}{#4}{}}%
}
%% Graphics figure with label
% [1:placement,] 2:relative width, 3:file name, 4:label
newcommand{figLab}[4]{%
ifthenelse{equal{#1}{}}%
{figCapLab{#2}{#3}{}{#4}}%
{figCapLab[#1]{#2}{#3}{}{#4}}%
}
Who can explain what went wrong?
macros parameters
New contributor
After I had a macro that worked, I tried to improve it by making some parameters optional.
Unfortunately the macro no longer works. Instead I'm getting errors I do not understand, for example:
LaTeX Warning: Label `{}####5' multiply defined.
! Illegal parameter number in definition of fLab.
The last code I tried looked like this:
%% Graphics figure with caption and label
% [1:placement,] 2:relative width, 3:file name[, 4:caption[, 5:label]]
newcommand{figCapLab}[5][htbp]{%
ifthenelse{equal{#5}{}}%
{renewcommand{fLab}{}}%
{renewcommand{fLab}{label{##5}}}%
ifthenelse{equal{#4}{}}%
{renewcommand{fCap}{fLab}}%
{renewcommand{fCap}{caption{fLab{small{}##4}}}}%
begin{figure}[#1]%
centering%
begin{minipage}[t]{#2textwidth}%
includegraphics[width=textwidth]{#3}% is width of surrounding minipage
fCap%
end{minipage}%
end{figure}
}
%% Graphics figure with caption
% [1:placement,] 2:relative width, 3:file name, 4:caption
newcommand{figCap}[4]{%
ifthenelse{equal{#1}{}}%
{figCapLab{#2}{#3}{#4}{}}%
{figCapLab[#1]{#2}{#3}{#4}{}}%
}
%% Graphics figure with label
% [1:placement,] 2:relative width, 3:file name, 4:label
newcommand{figLab}[4]{%
ifthenelse{equal{#1}{}}%
{figCapLab{#2}{#3}{}{#4}}%
{figCapLab[#1]{#2}{#3}{}{#4}}%
}
Who can explain what went wrong?
macros parameters
macros parameters
New contributor
New contributor
New contributor
asked 5 mins ago
U. WindlU. Windl
1031
1031
New contributor
New contributor
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
U. Windl is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f477627%2fhow-to-define-a-macro-with-multiple-optional-parameters%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
U. Windl is a new contributor. Be nice, and check out our Code of Conduct.
U. Windl is a new contributor. Be nice, and check out our Code of Conduct.
U. Windl is a new contributor. Be nice, and check out our Code of Conduct.
U. Windl is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f477627%2fhow-to-define-a-macro-with-multiple-optional-parameters%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown