uneven tab for align text
How can I align program and ''(commas) in same vertical line
my code was
item [1.]quad Identifierquad program
item [2.]quad White_Spacequad' '
align white-space
add a comment |
How can I align program and ''(commas) in same vertical line
my code was
item [1.]quad Identifierquad program
item [2.]quad White_Spacequad' '
align white-space
Please provide a MWE that makes it easy to compile and alter your code.
– Bubaya
Feb 21 at 10:46
add a comment |
How can I align program and ''(commas) in same vertical line
my code was
item [1.]quad Identifierquad program
item [2.]quad White_Spacequad' '
align white-space
How can I align program and ''(commas) in same vertical line
my code was
item [1.]quad Identifierquad program
item [2.]quad White_Spacequad' '
align white-space
align white-space
asked Feb 21 at 10:00
BawanthaBawantha
202
202
Please provide a MWE that makes it easy to compile and alter your code.
– Bubaya
Feb 21 at 10:46
add a comment |
Please provide a MWE that makes it easy to compile and alter your code.
– Bubaya
Feb 21 at 10:46
Please provide a MWE that makes it easy to compile and alter your code.
– Bubaya
Feb 21 at 10:46
Please provide a MWE that makes it easy to compile and alter your code.
– Bubaya
Feb 21 at 10:46
add a comment |
2 Answers
2
active
oldest
votes
As Bubaya notes, one possibility is to put the "label" in a box of a fixed width, though I wouldn't "fiddle" with phantoms and the like. I've defined a command to do it. Further refinement (e.g. to automatically set the width to your longest label) would be desirable no doubt.
Note also:
- If you want an enumerated list, I'd ask for an enumerated list, not set the label by hand.
- I can't approve of adding
quad
s to put extra space after the item label. If the list is not as it should be, changelabelsep
and (if need be)labelwidth
. Any time you are adding ad hoc spacing commands you are (probably) doing something wrong.
And note finally: if this is being used for more than a single instance, I wouldn't do it. Do it properly. Set up a list-type: the thinking you have to do in setting it up repays itself again and again in ease of use and absence of error.
Both alternatives demonstrated below. I'd obviously put the list definition in the preamble in production.
documentclass{article}
usepackage{enumitem}
newcommand{parsedescription}[2]{%
makebox[2.5cm][l]{#1}{#2}}
begin{document}
section{Hand rolled}
This is a hand-rolled version
begin{itemize}
item Output of scanner:
begin{enumerate}
itemparsedescription{Identifier}{program}
itemparsedescription{White_Space}{' '}
end{enumerate}
end{itemize}
section{Properly done}
And this is, much more semantically correct:
newcounter{parsecounter}
newlist{parse}{description}{1}
setlist[parse]{style=sameline,
labelwidth=3cm,
leftmargin=!,
labelindent=1em,
font=normalfont,
before={%
setcounter{parsecounter}{0}%
renewcommandmakelabel[1]{%
stepcounter{parsecounter}%
arabic{parsecounter}.enspace##1}}}
begin{itemize}
item Output of scanner:
begin{parse}
item[Identifier]program
item[White_Space]' '
end{parse}
end{itemize}
end{document}
add a comment |
If using a table is not an option for you, you can always fiddle around manually with phantom
or hphantom
, makebox
and widthof
, of which the latter is provided by the calc
package. So, to have your " underneath the word 'program', you can do:
documentclass{article}
usepackage{calc}
begin{document}
begin{enumerate}
item makebox[widthof{White_Space}][l]{Identifier}quad program
item White_Space quad makebox[widthof{program}]{''}
end{enumerate}
end{document}
However, if this is to be a lengthy list, consider using the tabular
environment.
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%2f475969%2funeven-tab-for-align-text%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
As Bubaya notes, one possibility is to put the "label" in a box of a fixed width, though I wouldn't "fiddle" with phantoms and the like. I've defined a command to do it. Further refinement (e.g. to automatically set the width to your longest label) would be desirable no doubt.
Note also:
- If you want an enumerated list, I'd ask for an enumerated list, not set the label by hand.
- I can't approve of adding
quad
s to put extra space after the item label. If the list is not as it should be, changelabelsep
and (if need be)labelwidth
. Any time you are adding ad hoc spacing commands you are (probably) doing something wrong.
And note finally: if this is being used for more than a single instance, I wouldn't do it. Do it properly. Set up a list-type: the thinking you have to do in setting it up repays itself again and again in ease of use and absence of error.
Both alternatives demonstrated below. I'd obviously put the list definition in the preamble in production.
documentclass{article}
usepackage{enumitem}
newcommand{parsedescription}[2]{%
makebox[2.5cm][l]{#1}{#2}}
begin{document}
section{Hand rolled}
This is a hand-rolled version
begin{itemize}
item Output of scanner:
begin{enumerate}
itemparsedescription{Identifier}{program}
itemparsedescription{White_Space}{' '}
end{enumerate}
end{itemize}
section{Properly done}
And this is, much more semantically correct:
newcounter{parsecounter}
newlist{parse}{description}{1}
setlist[parse]{style=sameline,
labelwidth=3cm,
leftmargin=!,
labelindent=1em,
font=normalfont,
before={%
setcounter{parsecounter}{0}%
renewcommandmakelabel[1]{%
stepcounter{parsecounter}%
arabic{parsecounter}.enspace##1}}}
begin{itemize}
item Output of scanner:
begin{parse}
item[Identifier]program
item[White_Space]' '
end{parse}
end{itemize}
end{document}
add a comment |
As Bubaya notes, one possibility is to put the "label" in a box of a fixed width, though I wouldn't "fiddle" with phantoms and the like. I've defined a command to do it. Further refinement (e.g. to automatically set the width to your longest label) would be desirable no doubt.
Note also:
- If you want an enumerated list, I'd ask for an enumerated list, not set the label by hand.
- I can't approve of adding
quad
s to put extra space after the item label. If the list is not as it should be, changelabelsep
and (if need be)labelwidth
. Any time you are adding ad hoc spacing commands you are (probably) doing something wrong.
And note finally: if this is being used for more than a single instance, I wouldn't do it. Do it properly. Set up a list-type: the thinking you have to do in setting it up repays itself again and again in ease of use and absence of error.
Both alternatives demonstrated below. I'd obviously put the list definition in the preamble in production.
documentclass{article}
usepackage{enumitem}
newcommand{parsedescription}[2]{%
makebox[2.5cm][l]{#1}{#2}}
begin{document}
section{Hand rolled}
This is a hand-rolled version
begin{itemize}
item Output of scanner:
begin{enumerate}
itemparsedescription{Identifier}{program}
itemparsedescription{White_Space}{' '}
end{enumerate}
end{itemize}
section{Properly done}
And this is, much more semantically correct:
newcounter{parsecounter}
newlist{parse}{description}{1}
setlist[parse]{style=sameline,
labelwidth=3cm,
leftmargin=!,
labelindent=1em,
font=normalfont,
before={%
setcounter{parsecounter}{0}%
renewcommandmakelabel[1]{%
stepcounter{parsecounter}%
arabic{parsecounter}.enspace##1}}}
begin{itemize}
item Output of scanner:
begin{parse}
item[Identifier]program
item[White_Space]' '
end{parse}
end{itemize}
end{document}
add a comment |
As Bubaya notes, one possibility is to put the "label" in a box of a fixed width, though I wouldn't "fiddle" with phantoms and the like. I've defined a command to do it. Further refinement (e.g. to automatically set the width to your longest label) would be desirable no doubt.
Note also:
- If you want an enumerated list, I'd ask for an enumerated list, not set the label by hand.
- I can't approve of adding
quad
s to put extra space after the item label. If the list is not as it should be, changelabelsep
and (if need be)labelwidth
. Any time you are adding ad hoc spacing commands you are (probably) doing something wrong.
And note finally: if this is being used for more than a single instance, I wouldn't do it. Do it properly. Set up a list-type: the thinking you have to do in setting it up repays itself again and again in ease of use and absence of error.
Both alternatives demonstrated below. I'd obviously put the list definition in the preamble in production.
documentclass{article}
usepackage{enumitem}
newcommand{parsedescription}[2]{%
makebox[2.5cm][l]{#1}{#2}}
begin{document}
section{Hand rolled}
This is a hand-rolled version
begin{itemize}
item Output of scanner:
begin{enumerate}
itemparsedescription{Identifier}{program}
itemparsedescription{White_Space}{' '}
end{enumerate}
end{itemize}
section{Properly done}
And this is, much more semantically correct:
newcounter{parsecounter}
newlist{parse}{description}{1}
setlist[parse]{style=sameline,
labelwidth=3cm,
leftmargin=!,
labelindent=1em,
font=normalfont,
before={%
setcounter{parsecounter}{0}%
renewcommandmakelabel[1]{%
stepcounter{parsecounter}%
arabic{parsecounter}.enspace##1}}}
begin{itemize}
item Output of scanner:
begin{parse}
item[Identifier]program
item[White_Space]' '
end{parse}
end{itemize}
end{document}
As Bubaya notes, one possibility is to put the "label" in a box of a fixed width, though I wouldn't "fiddle" with phantoms and the like. I've defined a command to do it. Further refinement (e.g. to automatically set the width to your longest label) would be desirable no doubt.
Note also:
- If you want an enumerated list, I'd ask for an enumerated list, not set the label by hand.
- I can't approve of adding
quad
s to put extra space after the item label. If the list is not as it should be, changelabelsep
and (if need be)labelwidth
. Any time you are adding ad hoc spacing commands you are (probably) doing something wrong.
And note finally: if this is being used for more than a single instance, I wouldn't do it. Do it properly. Set up a list-type: the thinking you have to do in setting it up repays itself again and again in ease of use and absence of error.
Both alternatives demonstrated below. I'd obviously put the list definition in the preamble in production.
documentclass{article}
usepackage{enumitem}
newcommand{parsedescription}[2]{%
makebox[2.5cm][l]{#1}{#2}}
begin{document}
section{Hand rolled}
This is a hand-rolled version
begin{itemize}
item Output of scanner:
begin{enumerate}
itemparsedescription{Identifier}{program}
itemparsedescription{White_Space}{' '}
end{enumerate}
end{itemize}
section{Properly done}
And this is, much more semantically correct:
newcounter{parsecounter}
newlist{parse}{description}{1}
setlist[parse]{style=sameline,
labelwidth=3cm,
leftmargin=!,
labelindent=1em,
font=normalfont,
before={%
setcounter{parsecounter}{0}%
renewcommandmakelabel[1]{%
stepcounter{parsecounter}%
arabic{parsecounter}.enspace##1}}}
begin{itemize}
item Output of scanner:
begin{parse}
item[Identifier]program
item[White_Space]' '
end{parse}
end{itemize}
end{document}
edited Feb 21 at 13:52
answered Feb 21 at 12:03
Paul StanleyPaul Stanley
14.8k42848
14.8k42848
add a comment |
add a comment |
If using a table is not an option for you, you can always fiddle around manually with phantom
or hphantom
, makebox
and widthof
, of which the latter is provided by the calc
package. So, to have your " underneath the word 'program', you can do:
documentclass{article}
usepackage{calc}
begin{document}
begin{enumerate}
item makebox[widthof{White_Space}][l]{Identifier}quad program
item White_Space quad makebox[widthof{program}]{''}
end{enumerate}
end{document}
However, if this is to be a lengthy list, consider using the tabular
environment.
add a comment |
If using a table is not an option for you, you can always fiddle around manually with phantom
or hphantom
, makebox
and widthof
, of which the latter is provided by the calc
package. So, to have your " underneath the word 'program', you can do:
documentclass{article}
usepackage{calc}
begin{document}
begin{enumerate}
item makebox[widthof{White_Space}][l]{Identifier}quad program
item White_Space quad makebox[widthof{program}]{''}
end{enumerate}
end{document}
However, if this is to be a lengthy list, consider using the tabular
environment.
add a comment |
If using a table is not an option for you, you can always fiddle around manually with phantom
or hphantom
, makebox
and widthof
, of which the latter is provided by the calc
package. So, to have your " underneath the word 'program', you can do:
documentclass{article}
usepackage{calc}
begin{document}
begin{enumerate}
item makebox[widthof{White_Space}][l]{Identifier}quad program
item White_Space quad makebox[widthof{program}]{''}
end{enumerate}
end{document}
However, if this is to be a lengthy list, consider using the tabular
environment.
If using a table is not an option for you, you can always fiddle around manually with phantom
or hphantom
, makebox
and widthof
, of which the latter is provided by the calc
package. So, to have your " underneath the word 'program', you can do:
documentclass{article}
usepackage{calc}
begin{document}
begin{enumerate}
item makebox[widthof{White_Space}][l]{Identifier}quad program
item White_Space quad makebox[widthof{program}]{''}
end{enumerate}
end{document}
However, if this is to be a lengthy list, consider using the tabular
environment.
answered Feb 21 at 10:54
BubayaBubaya
657310
657310
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%2f475969%2funeven-tab-for-align-text%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
Please provide a MWE that makes it easy to compile and alter your code.
– Bubaya
Feb 21 at 10:46