Align elements inside a newcommand
I made this newcommand boldAcr:
makeatletter % we need to use kernel commands
newcommand{boldAcr[1]}{MakeTextUppercase{textbf{#1}}@boldAcrOne}
newcommand@boldAcrOne{@ifnextcharstopBold{@boldSend}{@boldAcrTwo}}
newcommand@boldAcrTwo[1]{@boldAcrThree{#1}@boldAcrOne%restart the recursion
}
newcommand@boldAcrThree[1]{ fb{#1}} %Space
newcommand@boldSend[1]{% The argument is stopBold
}
makeatother
newcommand{fb}[1]{dofb#1}
newcommand{dofb}[1]{MakeTextUppercase{textbf{#1}}}
and I call it this way:
boldAcr[owasp] {open} {web} {application} {security} {project} stopBold \
boldAcr[xss] {cross} {site} {scripting} stopBold \
That is the result.

Is there a way to add spacing after the first word, to make all the others start from a specific point?
I mean like this:

spacing macros horizontal-alignment acronyms recursion
add a comment |
I made this newcommand boldAcr:
makeatletter % we need to use kernel commands
newcommand{boldAcr[1]}{MakeTextUppercase{textbf{#1}}@boldAcrOne}
newcommand@boldAcrOne{@ifnextcharstopBold{@boldSend}{@boldAcrTwo}}
newcommand@boldAcrTwo[1]{@boldAcrThree{#1}@boldAcrOne%restart the recursion
}
newcommand@boldAcrThree[1]{ fb{#1}} %Space
newcommand@boldSend[1]{% The argument is stopBold
}
makeatother
newcommand{fb}[1]{dofb#1}
newcommand{dofb}[1]{MakeTextUppercase{textbf{#1}}}
and I call it this way:
boldAcr[owasp] {open} {web} {application} {security} {project} stopBold \
boldAcr[xss] {cross} {site} {scripting} stopBold \
That is the result.

Is there a way to add spacing after the first word, to make all the others start from a specific point?
I mean like this:

spacing macros horizontal-alignment acronyms recursion
add a comment |
I made this newcommand boldAcr:
makeatletter % we need to use kernel commands
newcommand{boldAcr[1]}{MakeTextUppercase{textbf{#1}}@boldAcrOne}
newcommand@boldAcrOne{@ifnextcharstopBold{@boldSend}{@boldAcrTwo}}
newcommand@boldAcrTwo[1]{@boldAcrThree{#1}@boldAcrOne%restart the recursion
}
newcommand@boldAcrThree[1]{ fb{#1}} %Space
newcommand@boldSend[1]{% The argument is stopBold
}
makeatother
newcommand{fb}[1]{dofb#1}
newcommand{dofb}[1]{MakeTextUppercase{textbf{#1}}}
and I call it this way:
boldAcr[owasp] {open} {web} {application} {security} {project} stopBold \
boldAcr[xss] {cross} {site} {scripting} stopBold \
That is the result.

Is there a way to add spacing after the first word, to make all the others start from a specific point?
I mean like this:

spacing macros horizontal-alignment acronyms recursion
I made this newcommand boldAcr:
makeatletter % we need to use kernel commands
newcommand{boldAcr[1]}{MakeTextUppercase{textbf{#1}}@boldAcrOne}
newcommand@boldAcrOne{@ifnextcharstopBold{@boldSend}{@boldAcrTwo}}
newcommand@boldAcrTwo[1]{@boldAcrThree{#1}@boldAcrOne%restart the recursion
}
newcommand@boldAcrThree[1]{ fb{#1}} %Space
newcommand@boldSend[1]{% The argument is stopBold
}
makeatother
newcommand{fb}[1]{dofb#1}
newcommand{dofb}[1]{MakeTextUppercase{textbf{#1}}}
and I call it this way:
boldAcr[owasp] {open} {web} {application} {security} {project} stopBold \
boldAcr[xss] {cross} {site} {scripting} stopBold \
That is the result.

Is there a way to add spacing after the first word, to make all the others start from a specific point?
I mean like this:

spacing macros horizontal-alignment acronyms recursion
spacing macros horizontal-alignment acronyms recursion
edited 4 hours ago
David Carlisle
488k4111271872
488k4111271872
asked 5 hours ago
ScTALEScTALE
1766
1766
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
I think I'd use a simpler input syntax, perhaps

documentclass{article}
defboldAcr#1 {makebox[2cm][l]{textbf{MakeUppercase{#1}}} boldAcrB}
defboldAcrB#1 {ifx\#1parelseboldAcrC#1 expandafterboldAcrBfi}
defboldAcrC#1{textbf{MakeUppercase{#1}}}
begin{document}
boldAcr owasp open web application security project \
boldAcr xss cross site scripting \
end{document}
1
you could of course addmakebox[2cm][l]{textbf{MakeUppercaseto your version to force the first word to be 2cm wide, you don't have to change the input syntax.
– David Carlisle
4 hours ago
Thank you, both methods work
– ScTALE
4 hours ago
add a comment |
You can do better with xparse:
documentclass{article}
usepackage{xparse}
newlength{boldAcrwidth}
setlength{boldAcrwidth}{2cm}
NewDocumentCommand{boldAcr}{m >{SplitList{ }}m}{%
makebox[boldAcrwidth][l]{bfseriesMakeUppercase{#1}}%
ProcessList{#2}{boldAcrFirst}%
unskip
}
NewDocumentCommand{boldAcrFirst}{m}{%
boldAcrFirstAux#1 % we want a space
}
NewDocumentCommand{boldAcrFirstAux}{m}{%
textbf{MakeUppercase{#1}}%
}
begin{document}
begin{flushleft}
boldAcr{owasp}{open web application security project} \
boldAcr{xss}{cross site scripting} \
end{flushleft}
end{document}
The second argument is split at spaces; each item is passed to the macro boldAcrFirst that simply calls boldAcrFirstAux which only uses the first letter, making it boldface and uppercase, typesetting the rest normally and adding a trailing space. The last space is removed by unskip.

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%2f472630%2falign-elements-inside-a-newcommand%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
I think I'd use a simpler input syntax, perhaps

documentclass{article}
defboldAcr#1 {makebox[2cm][l]{textbf{MakeUppercase{#1}}} boldAcrB}
defboldAcrB#1 {ifx\#1parelseboldAcrC#1 expandafterboldAcrBfi}
defboldAcrC#1{textbf{MakeUppercase{#1}}}
begin{document}
boldAcr owasp open web application security project \
boldAcr xss cross site scripting \
end{document}
1
you could of course addmakebox[2cm][l]{textbf{MakeUppercaseto your version to force the first word to be 2cm wide, you don't have to change the input syntax.
– David Carlisle
4 hours ago
Thank you, both methods work
– ScTALE
4 hours ago
add a comment |
I think I'd use a simpler input syntax, perhaps

documentclass{article}
defboldAcr#1 {makebox[2cm][l]{textbf{MakeUppercase{#1}}} boldAcrB}
defboldAcrB#1 {ifx\#1parelseboldAcrC#1 expandafterboldAcrBfi}
defboldAcrC#1{textbf{MakeUppercase{#1}}}
begin{document}
boldAcr owasp open web application security project \
boldAcr xss cross site scripting \
end{document}
1
you could of course addmakebox[2cm][l]{textbf{MakeUppercaseto your version to force the first word to be 2cm wide, you don't have to change the input syntax.
– David Carlisle
4 hours ago
Thank you, both methods work
– ScTALE
4 hours ago
add a comment |
I think I'd use a simpler input syntax, perhaps

documentclass{article}
defboldAcr#1 {makebox[2cm][l]{textbf{MakeUppercase{#1}}} boldAcrB}
defboldAcrB#1 {ifx\#1parelseboldAcrC#1 expandafterboldAcrBfi}
defboldAcrC#1{textbf{MakeUppercase{#1}}}
begin{document}
boldAcr owasp open web application security project \
boldAcr xss cross site scripting \
end{document}
I think I'd use a simpler input syntax, perhaps

documentclass{article}
defboldAcr#1 {makebox[2cm][l]{textbf{MakeUppercase{#1}}} boldAcrB}
defboldAcrB#1 {ifx\#1parelseboldAcrC#1 expandafterboldAcrBfi}
defboldAcrC#1{textbf{MakeUppercase{#1}}}
begin{document}
boldAcr owasp open web application security project \
boldAcr xss cross site scripting \
end{document}
answered 4 hours ago
David CarlisleDavid Carlisle
488k4111271872
488k4111271872
1
you could of course addmakebox[2cm][l]{textbf{MakeUppercaseto your version to force the first word to be 2cm wide, you don't have to change the input syntax.
– David Carlisle
4 hours ago
Thank you, both methods work
– ScTALE
4 hours ago
add a comment |
1
you could of course addmakebox[2cm][l]{textbf{MakeUppercaseto your version to force the first word to be 2cm wide, you don't have to change the input syntax.
– David Carlisle
4 hours ago
Thank you, both methods work
– ScTALE
4 hours ago
1
1
you could of course add
makebox[2cm][l]{textbf{MakeUppercase to your version to force the first word to be 2cm wide, you don't have to change the input syntax.– David Carlisle
4 hours ago
you could of course add
makebox[2cm][l]{textbf{MakeUppercase to your version to force the first word to be 2cm wide, you don't have to change the input syntax.– David Carlisle
4 hours ago
Thank you, both methods work
– ScTALE
4 hours ago
Thank you, both methods work
– ScTALE
4 hours ago
add a comment |
You can do better with xparse:
documentclass{article}
usepackage{xparse}
newlength{boldAcrwidth}
setlength{boldAcrwidth}{2cm}
NewDocumentCommand{boldAcr}{m >{SplitList{ }}m}{%
makebox[boldAcrwidth][l]{bfseriesMakeUppercase{#1}}%
ProcessList{#2}{boldAcrFirst}%
unskip
}
NewDocumentCommand{boldAcrFirst}{m}{%
boldAcrFirstAux#1 % we want a space
}
NewDocumentCommand{boldAcrFirstAux}{m}{%
textbf{MakeUppercase{#1}}%
}
begin{document}
begin{flushleft}
boldAcr{owasp}{open web application security project} \
boldAcr{xss}{cross site scripting} \
end{flushleft}
end{document}
The second argument is split at spaces; each item is passed to the macro boldAcrFirst that simply calls boldAcrFirstAux which only uses the first letter, making it boldface and uppercase, typesetting the rest normally and adding a trailing space. The last space is removed by unskip.

add a comment |
You can do better with xparse:
documentclass{article}
usepackage{xparse}
newlength{boldAcrwidth}
setlength{boldAcrwidth}{2cm}
NewDocumentCommand{boldAcr}{m >{SplitList{ }}m}{%
makebox[boldAcrwidth][l]{bfseriesMakeUppercase{#1}}%
ProcessList{#2}{boldAcrFirst}%
unskip
}
NewDocumentCommand{boldAcrFirst}{m}{%
boldAcrFirstAux#1 % we want a space
}
NewDocumentCommand{boldAcrFirstAux}{m}{%
textbf{MakeUppercase{#1}}%
}
begin{document}
begin{flushleft}
boldAcr{owasp}{open web application security project} \
boldAcr{xss}{cross site scripting} \
end{flushleft}
end{document}
The second argument is split at spaces; each item is passed to the macro boldAcrFirst that simply calls boldAcrFirstAux which only uses the first letter, making it boldface and uppercase, typesetting the rest normally and adding a trailing space. The last space is removed by unskip.

add a comment |
You can do better with xparse:
documentclass{article}
usepackage{xparse}
newlength{boldAcrwidth}
setlength{boldAcrwidth}{2cm}
NewDocumentCommand{boldAcr}{m >{SplitList{ }}m}{%
makebox[boldAcrwidth][l]{bfseriesMakeUppercase{#1}}%
ProcessList{#2}{boldAcrFirst}%
unskip
}
NewDocumentCommand{boldAcrFirst}{m}{%
boldAcrFirstAux#1 % we want a space
}
NewDocumentCommand{boldAcrFirstAux}{m}{%
textbf{MakeUppercase{#1}}%
}
begin{document}
begin{flushleft}
boldAcr{owasp}{open web application security project} \
boldAcr{xss}{cross site scripting} \
end{flushleft}
end{document}
The second argument is split at spaces; each item is passed to the macro boldAcrFirst that simply calls boldAcrFirstAux which only uses the first letter, making it boldface and uppercase, typesetting the rest normally and adding a trailing space. The last space is removed by unskip.

You can do better with xparse:
documentclass{article}
usepackage{xparse}
newlength{boldAcrwidth}
setlength{boldAcrwidth}{2cm}
NewDocumentCommand{boldAcr}{m >{SplitList{ }}m}{%
makebox[boldAcrwidth][l]{bfseriesMakeUppercase{#1}}%
ProcessList{#2}{boldAcrFirst}%
unskip
}
NewDocumentCommand{boldAcrFirst}{m}{%
boldAcrFirstAux#1 % we want a space
}
NewDocumentCommand{boldAcrFirstAux}{m}{%
textbf{MakeUppercase{#1}}%
}
begin{document}
begin{flushleft}
boldAcr{owasp}{open web application security project} \
boldAcr{xss}{cross site scripting} \
end{flushleft}
end{document}
The second argument is split at spaces; each item is passed to the macro boldAcrFirst that simply calls boldAcrFirstAux which only uses the first letter, making it boldface and uppercase, typesetting the rest normally and adding a trailing space. The last space is removed by unskip.

answered 3 hours ago
egregegreg
716k8619033189
716k8619033189
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%2f472630%2falign-elements-inside-a-newcommand%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