Command “root” and “subcommands”“Closed” (square) root symbolCan a command begin and end within...
Papers on arXiv solving the same problem at the same time
Evaluated vs. unevaluated Association
Book with the Latin quote 'nihil superbus' meaning 'nothing above us'
Semantic difference between regular and irregular 'backen'
Very slow boot time and poor perfomance
What to look for in a spotting scope?
Why does Windows store Wi-Fi passwords in a reversible format?
Redacting URLs as an email-phishing preventative?
Does Yeshayahu 43:10b / 43:13a imply HaShem was created?
Limitations with dynamical systems vs. PDEs?
How were medieval castles built in swamps or marshes without draining them?
Boot Windows from SAN
Breaker Mapping Questions
Why is proof-of-work required in Bitcoin?
What is the difference between "Grippe" and "Männergrippe"?
Duplicate instruments in unison in an orchestra
When one problem is added to the previous one
Joining lists with same elements
Should I stick with American terminology in my English set young adult book?
Could this kind of inaccurate sacrifice be countered?
Who was the most successful German spy against Great Britain in WWII, from the contemporary German perspective?
What does "rel" in `mathrel` and `stackrel` stands for?
Are the players on the same team as the DM?
How do proponents of Sola Scriptura address the ministry of those Apostles who authored no parts of Scripture?
Command “root” and “subcommands”
“Closed” (square) root symbolCan a command begin and end within {} and {}?Defining command containing pagebreak, and boxesnew command and L with strokeUnicode macros for square root and integralNew command for filtered colimits and limitsCommand inscribed in commandCustomized rootDefine a command including paranthesis and bracketsFloating point square root symbol
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
Greetings from Switzerland,
(I apologise for this poorly worded question)
Is it possible to create a command "root" (e.g. law
, with a fixed structure as detailed below, never used in the document itself) and subsequently create other "subcommands" (e.g. lawbueg
, lawbuev
, lawkbueg
) depending on my needs?
Here is a MWE:
documentclass{article}
usepackage{xstring}
usepackage{xifthen}
usepackage{xparse}
DeclareDocumentCommandlaw{ m m g g}{%
{Art.~#2%
IfNoValueF {#3} {%
IfInteger{#3}%
{~Abs. #3}%
{~lit. #3}%
}%
IfNoValueF {#4} {%
IfInteger{#4}%
{~Ziff. #4}%
{~lit. #4}%
}%
~#1}%
}
% law-command "generator"
newcommand[2]{createlaw}{<unsure how to proceed here>}
% #1 needs to be stuck right after law and before the first {, in order to create a new separate command every time I use createlaw
% #2 this argument needs to correspond to #1 in law above
%Examples:
%createlaw{bueg}{BüG}
%createlaw{kbueg}{KBüG}
begin{document}
Hello, I'm lawbueg{21}{2}{b}, and I'm lawkbueg{43}{1}.
end{document}
I'd be grateful for any help.
macros
add a comment |
Greetings from Switzerland,
(I apologise for this poorly worded question)
Is it possible to create a command "root" (e.g. law
, with a fixed structure as detailed below, never used in the document itself) and subsequently create other "subcommands" (e.g. lawbueg
, lawbuev
, lawkbueg
) depending on my needs?
Here is a MWE:
documentclass{article}
usepackage{xstring}
usepackage{xifthen}
usepackage{xparse}
DeclareDocumentCommandlaw{ m m g g}{%
{Art.~#2%
IfNoValueF {#3} {%
IfInteger{#3}%
{~Abs. #3}%
{~lit. #3}%
}%
IfNoValueF {#4} {%
IfInteger{#4}%
{~Ziff. #4}%
{~lit. #4}%
}%
~#1}%
}
% law-command "generator"
newcommand[2]{createlaw}{<unsure how to proceed here>}
% #1 needs to be stuck right after law and before the first {, in order to create a new separate command every time I use createlaw
% #2 this argument needs to correspond to #1 in law above
%Examples:
%createlaw{bueg}{BüG}
%createlaw{kbueg}{KBüG}
begin{document}
Hello, I'm lawbueg{21}{2}{b}, and I'm lawkbueg{43}{1}.
end{document}
I'd be grateful for any help.
macros
add a comment |
Greetings from Switzerland,
(I apologise for this poorly worded question)
Is it possible to create a command "root" (e.g. law
, with a fixed structure as detailed below, never used in the document itself) and subsequently create other "subcommands" (e.g. lawbueg
, lawbuev
, lawkbueg
) depending on my needs?
Here is a MWE:
documentclass{article}
usepackage{xstring}
usepackage{xifthen}
usepackage{xparse}
DeclareDocumentCommandlaw{ m m g g}{%
{Art.~#2%
IfNoValueF {#3} {%
IfInteger{#3}%
{~Abs. #3}%
{~lit. #3}%
}%
IfNoValueF {#4} {%
IfInteger{#4}%
{~Ziff. #4}%
{~lit. #4}%
}%
~#1}%
}
% law-command "generator"
newcommand[2]{createlaw}{<unsure how to proceed here>}
% #1 needs to be stuck right after law and before the first {, in order to create a new separate command every time I use createlaw
% #2 this argument needs to correspond to #1 in law above
%Examples:
%createlaw{bueg}{BüG}
%createlaw{kbueg}{KBüG}
begin{document}
Hello, I'm lawbueg{21}{2}{b}, and I'm lawkbueg{43}{1}.
end{document}
I'd be grateful for any help.
macros
Greetings from Switzerland,
(I apologise for this poorly worded question)
Is it possible to create a command "root" (e.g. law
, with a fixed structure as detailed below, never used in the document itself) and subsequently create other "subcommands" (e.g. lawbueg
, lawbuev
, lawkbueg
) depending on my needs?
Here is a MWE:
documentclass{article}
usepackage{xstring}
usepackage{xifthen}
usepackage{xparse}
DeclareDocumentCommandlaw{ m m g g}{%
{Art.~#2%
IfNoValueF {#3} {%
IfInteger{#3}%
{~Abs. #3}%
{~lit. #3}%
}%
IfNoValueF {#4} {%
IfInteger{#4}%
{~Ziff. #4}%
{~lit. #4}%
}%
~#1}%
}
% law-command "generator"
newcommand[2]{createlaw}{<unsure how to proceed here>}
% #1 needs to be stuck right after law and before the first {, in order to create a new separate command every time I use createlaw
% #2 this argument needs to correspond to #1 in law above
%Examples:
%createlaw{bueg}{BüG}
%createlaw{kbueg}{KBüG}
begin{document}
Hello, I'm lawbueg{21}{2}{b}, and I'm lawkbueg{43}{1}.
end{document}
I'd be grateful for any help.
macros
macros
asked 14 hours ago
Archein von DrakenovArchein von Drakenov
436 bronze badges
436 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Here is a way that works for this MWE but I don't really know if it works for you (for your real needs):
documentclass{article}
usepackage{xstring}
usepackage{xifthen}
usepackage{xparse}
DeclareDocumentCommandlaw{ m m g g}{%
{Art.~#2%
IfNoValueF {#3} {%
IfInteger{#3}%
{~Abs. #3}%
{~lit. #3}%
}%
IfNoValueF {#4} {%
IfInteger{#4}%
{~Ziff. #4}%
{~lit. #4}%
}%
~#1}%
}
% law-command "generator"
newcommand{createlaw}[2]{%
edeftemp{law{#2}}
expandafterexpandafterexpandafterglobalexpandafterletcsname law#1endcsnametemp
}
% #1 needs to be stuck right after law and before the first {, in order to create a new separate command every time I use createlaw
% #2 this argument needs to correspond to #1 in law above
%Examples:
createlaw{bueg}{BüG}
createlaw{kbueg}{KBüG}
begin{document}
Hello, I'm lawbueg{21}{2}{b}, and I'm lawkbueg{43}{1}.
end{document}
Output:
Hello, I’m Art. 21 Abs. 2 lit. b BG, and I’m Art. 43 Abs. 1 KBG.
1
Addusepackage[utf8]{inputenc}
for not losing characters like I did :P
– koleygr
14 hours ago
Seems to work fine, I was unsure on how to use csname (as seen in other Q&As), thanks a lot!
– Archein von Drakenov
14 hours ago
add a comment |
I would avoid the g
argument type. Anyway, here's a solution that also implements IfIntegerTF
in place of IfInteger
of xstring
.
documentclass{article}
usepackage{xparse}
NewDocumentCommandlaw{ m m g g}{%
Art.~#2%
IfNoValueF{#3}{%
IfIntegerTF{#3}%
{~Abs. #3}%
{~lit. #3}%
}%
IfNoValueF{#4}{%
IfIntegerTF{#4}%
{~Ziff. #4}%
{~lit. #4}%
}%
~#1%
}
ExplSyntaxOn
% law-command "generator"
NewDocumentCommand{createlaw}{mm}
{
% creates law#1
% #2 is the first argument to law
cs_new_protected:cpn { law#1 } { law{#2} }
}
NewDocumentCommand{IfIntegerTF}{mmm}
{% [+-]? is zero or one sign; d+ is one or more digits
regex_match:nnTF { A [+-]? d+ Z } { #1 } { #2 } { #3 }
}
ExplSyntaxOff
createlaw{bueg}{BüG}
createlaw{kbueg}{KBüG}
begin{document}
Hello, I'm lawbueg{21}{2}{b}, and I'm lawkbueg{43}{1}.
end{document}
add a comment |
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
});
}
});
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%2f505655%2fcommand-root-and-subcommands%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here is a way that works for this MWE but I don't really know if it works for you (for your real needs):
documentclass{article}
usepackage{xstring}
usepackage{xifthen}
usepackage{xparse}
DeclareDocumentCommandlaw{ m m g g}{%
{Art.~#2%
IfNoValueF {#3} {%
IfInteger{#3}%
{~Abs. #3}%
{~lit. #3}%
}%
IfNoValueF {#4} {%
IfInteger{#4}%
{~Ziff. #4}%
{~lit. #4}%
}%
~#1}%
}
% law-command "generator"
newcommand{createlaw}[2]{%
edeftemp{law{#2}}
expandafterexpandafterexpandafterglobalexpandafterletcsname law#1endcsnametemp
}
% #1 needs to be stuck right after law and before the first {, in order to create a new separate command every time I use createlaw
% #2 this argument needs to correspond to #1 in law above
%Examples:
createlaw{bueg}{BüG}
createlaw{kbueg}{KBüG}
begin{document}
Hello, I'm lawbueg{21}{2}{b}, and I'm lawkbueg{43}{1}.
end{document}
Output:
Hello, I’m Art. 21 Abs. 2 lit. b BG, and I’m Art. 43 Abs. 1 KBG.
1
Addusepackage[utf8]{inputenc}
for not losing characters like I did :P
– koleygr
14 hours ago
Seems to work fine, I was unsure on how to use csname (as seen in other Q&As), thanks a lot!
– Archein von Drakenov
14 hours ago
add a comment |
Here is a way that works for this MWE but I don't really know if it works for you (for your real needs):
documentclass{article}
usepackage{xstring}
usepackage{xifthen}
usepackage{xparse}
DeclareDocumentCommandlaw{ m m g g}{%
{Art.~#2%
IfNoValueF {#3} {%
IfInteger{#3}%
{~Abs. #3}%
{~lit. #3}%
}%
IfNoValueF {#4} {%
IfInteger{#4}%
{~Ziff. #4}%
{~lit. #4}%
}%
~#1}%
}
% law-command "generator"
newcommand{createlaw}[2]{%
edeftemp{law{#2}}
expandafterexpandafterexpandafterglobalexpandafterletcsname law#1endcsnametemp
}
% #1 needs to be stuck right after law and before the first {, in order to create a new separate command every time I use createlaw
% #2 this argument needs to correspond to #1 in law above
%Examples:
createlaw{bueg}{BüG}
createlaw{kbueg}{KBüG}
begin{document}
Hello, I'm lawbueg{21}{2}{b}, and I'm lawkbueg{43}{1}.
end{document}
Output:
Hello, I’m Art. 21 Abs. 2 lit. b BG, and I’m Art. 43 Abs. 1 KBG.
1
Addusepackage[utf8]{inputenc}
for not losing characters like I did :P
– koleygr
14 hours ago
Seems to work fine, I was unsure on how to use csname (as seen in other Q&As), thanks a lot!
– Archein von Drakenov
14 hours ago
add a comment |
Here is a way that works for this MWE but I don't really know if it works for you (for your real needs):
documentclass{article}
usepackage{xstring}
usepackage{xifthen}
usepackage{xparse}
DeclareDocumentCommandlaw{ m m g g}{%
{Art.~#2%
IfNoValueF {#3} {%
IfInteger{#3}%
{~Abs. #3}%
{~lit. #3}%
}%
IfNoValueF {#4} {%
IfInteger{#4}%
{~Ziff. #4}%
{~lit. #4}%
}%
~#1}%
}
% law-command "generator"
newcommand{createlaw}[2]{%
edeftemp{law{#2}}
expandafterexpandafterexpandafterglobalexpandafterletcsname law#1endcsnametemp
}
% #1 needs to be stuck right after law and before the first {, in order to create a new separate command every time I use createlaw
% #2 this argument needs to correspond to #1 in law above
%Examples:
createlaw{bueg}{BüG}
createlaw{kbueg}{KBüG}
begin{document}
Hello, I'm lawbueg{21}{2}{b}, and I'm lawkbueg{43}{1}.
end{document}
Output:
Hello, I’m Art. 21 Abs. 2 lit. b BG, and I’m Art. 43 Abs. 1 KBG.
Here is a way that works for this MWE but I don't really know if it works for you (for your real needs):
documentclass{article}
usepackage{xstring}
usepackage{xifthen}
usepackage{xparse}
DeclareDocumentCommandlaw{ m m g g}{%
{Art.~#2%
IfNoValueF {#3} {%
IfInteger{#3}%
{~Abs. #3}%
{~lit. #3}%
}%
IfNoValueF {#4} {%
IfInteger{#4}%
{~Ziff. #4}%
{~lit. #4}%
}%
~#1}%
}
% law-command "generator"
newcommand{createlaw}[2]{%
edeftemp{law{#2}}
expandafterexpandafterexpandafterglobalexpandafterletcsname law#1endcsnametemp
}
% #1 needs to be stuck right after law and before the first {, in order to create a new separate command every time I use createlaw
% #2 this argument needs to correspond to #1 in law above
%Examples:
createlaw{bueg}{BüG}
createlaw{kbueg}{KBüG}
begin{document}
Hello, I'm lawbueg{21}{2}{b}, and I'm lawkbueg{43}{1}.
end{document}
Output:
Hello, I’m Art. 21 Abs. 2 lit. b BG, and I’m Art. 43 Abs. 1 KBG.
edited 14 hours ago
answered 14 hours ago
koleygrkoleygr
14.8k1 gold badge10 silver badges40 bronze badges
14.8k1 gold badge10 silver badges40 bronze badges
1
Addusepackage[utf8]{inputenc}
for not losing characters like I did :P
– koleygr
14 hours ago
Seems to work fine, I was unsure on how to use csname (as seen in other Q&As), thanks a lot!
– Archein von Drakenov
14 hours ago
add a comment |
1
Addusepackage[utf8]{inputenc}
for not losing characters like I did :P
– koleygr
14 hours ago
Seems to work fine, I was unsure on how to use csname (as seen in other Q&As), thanks a lot!
– Archein von Drakenov
14 hours ago
1
1
Add
usepackage[utf8]{inputenc}
for not losing characters like I did :P– koleygr
14 hours ago
Add
usepackage[utf8]{inputenc}
for not losing characters like I did :P– koleygr
14 hours ago
Seems to work fine, I was unsure on how to use csname (as seen in other Q&As), thanks a lot!
– Archein von Drakenov
14 hours ago
Seems to work fine, I was unsure on how to use csname (as seen in other Q&As), thanks a lot!
– Archein von Drakenov
14 hours ago
add a comment |
I would avoid the g
argument type. Anyway, here's a solution that also implements IfIntegerTF
in place of IfInteger
of xstring
.
documentclass{article}
usepackage{xparse}
NewDocumentCommandlaw{ m m g g}{%
Art.~#2%
IfNoValueF{#3}{%
IfIntegerTF{#3}%
{~Abs. #3}%
{~lit. #3}%
}%
IfNoValueF{#4}{%
IfIntegerTF{#4}%
{~Ziff. #4}%
{~lit. #4}%
}%
~#1%
}
ExplSyntaxOn
% law-command "generator"
NewDocumentCommand{createlaw}{mm}
{
% creates law#1
% #2 is the first argument to law
cs_new_protected:cpn { law#1 } { law{#2} }
}
NewDocumentCommand{IfIntegerTF}{mmm}
{% [+-]? is zero or one sign; d+ is one or more digits
regex_match:nnTF { A [+-]? d+ Z } { #1 } { #2 } { #3 }
}
ExplSyntaxOff
createlaw{bueg}{BüG}
createlaw{kbueg}{KBüG}
begin{document}
Hello, I'm lawbueg{21}{2}{b}, and I'm lawkbueg{43}{1}.
end{document}
add a comment |
I would avoid the g
argument type. Anyway, here's a solution that also implements IfIntegerTF
in place of IfInteger
of xstring
.
documentclass{article}
usepackage{xparse}
NewDocumentCommandlaw{ m m g g}{%
Art.~#2%
IfNoValueF{#3}{%
IfIntegerTF{#3}%
{~Abs. #3}%
{~lit. #3}%
}%
IfNoValueF{#4}{%
IfIntegerTF{#4}%
{~Ziff. #4}%
{~lit. #4}%
}%
~#1%
}
ExplSyntaxOn
% law-command "generator"
NewDocumentCommand{createlaw}{mm}
{
% creates law#1
% #2 is the first argument to law
cs_new_protected:cpn { law#1 } { law{#2} }
}
NewDocumentCommand{IfIntegerTF}{mmm}
{% [+-]? is zero or one sign; d+ is one or more digits
regex_match:nnTF { A [+-]? d+ Z } { #1 } { #2 } { #3 }
}
ExplSyntaxOff
createlaw{bueg}{BüG}
createlaw{kbueg}{KBüG}
begin{document}
Hello, I'm lawbueg{21}{2}{b}, and I'm lawkbueg{43}{1}.
end{document}
add a comment |
I would avoid the g
argument type. Anyway, here's a solution that also implements IfIntegerTF
in place of IfInteger
of xstring
.
documentclass{article}
usepackage{xparse}
NewDocumentCommandlaw{ m m g g}{%
Art.~#2%
IfNoValueF{#3}{%
IfIntegerTF{#3}%
{~Abs. #3}%
{~lit. #3}%
}%
IfNoValueF{#4}{%
IfIntegerTF{#4}%
{~Ziff. #4}%
{~lit. #4}%
}%
~#1%
}
ExplSyntaxOn
% law-command "generator"
NewDocumentCommand{createlaw}{mm}
{
% creates law#1
% #2 is the first argument to law
cs_new_protected:cpn { law#1 } { law{#2} }
}
NewDocumentCommand{IfIntegerTF}{mmm}
{% [+-]? is zero or one sign; d+ is one or more digits
regex_match:nnTF { A [+-]? d+ Z } { #1 } { #2 } { #3 }
}
ExplSyntaxOff
createlaw{bueg}{BüG}
createlaw{kbueg}{KBüG}
begin{document}
Hello, I'm lawbueg{21}{2}{b}, and I'm lawkbueg{43}{1}.
end{document}
I would avoid the g
argument type. Anyway, here's a solution that also implements IfIntegerTF
in place of IfInteger
of xstring
.
documentclass{article}
usepackage{xparse}
NewDocumentCommandlaw{ m m g g}{%
Art.~#2%
IfNoValueF{#3}{%
IfIntegerTF{#3}%
{~Abs. #3}%
{~lit. #3}%
}%
IfNoValueF{#4}{%
IfIntegerTF{#4}%
{~Ziff. #4}%
{~lit. #4}%
}%
~#1%
}
ExplSyntaxOn
% law-command "generator"
NewDocumentCommand{createlaw}{mm}
{
% creates law#1
% #2 is the first argument to law
cs_new_protected:cpn { law#1 } { law{#2} }
}
NewDocumentCommand{IfIntegerTF}{mmm}
{% [+-]? is zero or one sign; d+ is one or more digits
regex_match:nnTF { A [+-]? d+ Z } { #1 } { #2 } { #3 }
}
ExplSyntaxOff
createlaw{bueg}{BüG}
createlaw{kbueg}{KBüG}
begin{document}
Hello, I'm lawbueg{21}{2}{b}, and I'm lawkbueg{43}{1}.
end{document}
answered 8 hours ago
egregegreg
764k90 gold badges1997 silver badges3345 bronze badges
764k90 gold badges1997 silver badges3345 bronze badges
add a comment |
add a comment |
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%2f505655%2fcommand-root-and-subcommands%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