How to align horizontally line numbers with package algorithm2e
I'm trying to write an algorithm using the package algorithm2e.
This is my code:
usepackage[linesnumbered,ruled]{algorithm2e}
...
{footnotesize
IncMargin{1em}
begin{algorithm}[H]
SetAlgoVlined
SetAlgoNlRelativeSize{-1}
SetNlSkip{1em}
$ALIGNMENTS gets NEXT$;
BlankLine
While{$(C_{cov} > 0) wedge (|ALIGNMENTS| > 0)$}{
$NEXT gets 0$;
ForEach{$A in ALIGNMENTS$}{
$U gets checkAlignments(mu,A,C_{cov})$;
uIf{$|U| = 1$}{
$mu gets updateProfile(mu,U)$;
}
Else{
$NEXT = NEXT cup {A}$;
}
}
If{$|ALIGNMENTS| = |NEXT|$}{
$C_{cov} gets C_{cov} - 1$;
}
$ALIGNMENTS gets NEXT$;
}
BlankLine
KwRet{$mu$};
end{algorithm}
}
And this is the result:
The problem is that the line numbers are not properly aligned: for example the 9 is a lot more on the right than the 1.
So, how can I properly align them horizontally?
algorithms algorithm2e line-numbering algorithmicx algorithmic
add a comment |
I'm trying to write an algorithm using the package algorithm2e.
This is my code:
usepackage[linesnumbered,ruled]{algorithm2e}
...
{footnotesize
IncMargin{1em}
begin{algorithm}[H]
SetAlgoVlined
SetAlgoNlRelativeSize{-1}
SetNlSkip{1em}
$ALIGNMENTS gets NEXT$;
BlankLine
While{$(C_{cov} > 0) wedge (|ALIGNMENTS| > 0)$}{
$NEXT gets 0$;
ForEach{$A in ALIGNMENTS$}{
$U gets checkAlignments(mu,A,C_{cov})$;
uIf{$|U| = 1$}{
$mu gets updateProfile(mu,U)$;
}
Else{
$NEXT = NEXT cup {A}$;
}
}
If{$|ALIGNMENTS| = |NEXT|$}{
$C_{cov} gets C_{cov} - 1$;
}
$ALIGNMENTS gets NEXT$;
}
BlankLine
KwRet{$mu$};
end{algorithm}
}
And this is the result:
The problem is that the line numbers are not properly aligned: for example the 9 is a lot more on the right than the 1.
So, how can I properly align them horizontally?
algorithms algorithm2e line-numbering algorithmicx algorithmic
add a comment |
I'm trying to write an algorithm using the package algorithm2e.
This is my code:
usepackage[linesnumbered,ruled]{algorithm2e}
...
{footnotesize
IncMargin{1em}
begin{algorithm}[H]
SetAlgoVlined
SetAlgoNlRelativeSize{-1}
SetNlSkip{1em}
$ALIGNMENTS gets NEXT$;
BlankLine
While{$(C_{cov} > 0) wedge (|ALIGNMENTS| > 0)$}{
$NEXT gets 0$;
ForEach{$A in ALIGNMENTS$}{
$U gets checkAlignments(mu,A,C_{cov})$;
uIf{$|U| = 1$}{
$mu gets updateProfile(mu,U)$;
}
Else{
$NEXT = NEXT cup {A}$;
}
}
If{$|ALIGNMENTS| = |NEXT|$}{
$C_{cov} gets C_{cov} - 1$;
}
$ALIGNMENTS gets NEXT$;
}
BlankLine
KwRet{$mu$};
end{algorithm}
}
And this is the result:
The problem is that the line numbers are not properly aligned: for example the 9 is a lot more on the right than the 1.
So, how can I properly align them horizontally?
algorithms algorithm2e line-numbering algorithmicx algorithmic
I'm trying to write an algorithm using the package algorithm2e.
This is my code:
usepackage[linesnumbered,ruled]{algorithm2e}
...
{footnotesize
IncMargin{1em}
begin{algorithm}[H]
SetAlgoVlined
SetAlgoNlRelativeSize{-1}
SetNlSkip{1em}
$ALIGNMENTS gets NEXT$;
BlankLine
While{$(C_{cov} > 0) wedge (|ALIGNMENTS| > 0)$}{
$NEXT gets 0$;
ForEach{$A in ALIGNMENTS$}{
$U gets checkAlignments(mu,A,C_{cov})$;
uIf{$|U| = 1$}{
$mu gets updateProfile(mu,U)$;
}
Else{
$NEXT = NEXT cup {A}$;
}
}
If{$|ALIGNMENTS| = |NEXT|$}{
$C_{cov} gets C_{cov} - 1$;
}
$ALIGNMENTS gets NEXT$;
}
BlankLine
KwRet{$mu$};
end{algorithm}
}
And this is the result:
The problem is that the line numbers are not properly aligned: for example the 9 is a lot more on the right than the 1.
So, how can I properly align them horizontally?
algorithms algorithm2e line-numbering algorithmicx algorithmic
algorithms algorithm2e line-numbering algorithmicx algorithmic
asked Feb 25 at 11:40
TommyTommy
1
1
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Welcome to TeX.SE. From the documentation of algorithm2e you have:
documentclass[12pt]{article}
usepackage[linesnumbered,lined,boxed,commentsnumbered]{algorithm2e}
begin{document}
IncMargin{1em}
begin{algorithm}
$ALIGNMENTS gets NEXT$;
BlankLine
While{$(C_{cov} > 0) wedge (|ALIGNMENTS| > 0)$}{
$NEXT gets 0$;
ForEach{$A in ALIGNMENTS$}{
$U gets checkAlignments(mu,A,C_{cov})$;
uIf{$|U| = 1$}{
$mu gets updateProfile(mu,U)$;
}
Else{
$NEXT = NEXT cup {A}$;
}
}
If{$|ALIGNMENTS| = |NEXT|$}{
$C_{cov} gets C_{cov} - 1$;
}
$ALIGNMENTS gets NEXT$;
}
BlankLine
KwRet{$mu$};
DecMargin{1em}
end{algorithm}
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%2f476579%2fhow-to-align-horizontally-line-numbers-with-package-algorithm2e%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Welcome to TeX.SE. From the documentation of algorithm2e you have:
documentclass[12pt]{article}
usepackage[linesnumbered,lined,boxed,commentsnumbered]{algorithm2e}
begin{document}
IncMargin{1em}
begin{algorithm}
$ALIGNMENTS gets NEXT$;
BlankLine
While{$(C_{cov} > 0) wedge (|ALIGNMENTS| > 0)$}{
$NEXT gets 0$;
ForEach{$A in ALIGNMENTS$}{
$U gets checkAlignments(mu,A,C_{cov})$;
uIf{$|U| = 1$}{
$mu gets updateProfile(mu,U)$;
}
Else{
$NEXT = NEXT cup {A}$;
}
}
If{$|ALIGNMENTS| = |NEXT|$}{
$C_{cov} gets C_{cov} - 1$;
}
$ALIGNMENTS gets NEXT$;
}
BlankLine
KwRet{$mu$};
DecMargin{1em}
end{algorithm}
end{document}
add a comment |
Welcome to TeX.SE. From the documentation of algorithm2e you have:
documentclass[12pt]{article}
usepackage[linesnumbered,lined,boxed,commentsnumbered]{algorithm2e}
begin{document}
IncMargin{1em}
begin{algorithm}
$ALIGNMENTS gets NEXT$;
BlankLine
While{$(C_{cov} > 0) wedge (|ALIGNMENTS| > 0)$}{
$NEXT gets 0$;
ForEach{$A in ALIGNMENTS$}{
$U gets checkAlignments(mu,A,C_{cov})$;
uIf{$|U| = 1$}{
$mu gets updateProfile(mu,U)$;
}
Else{
$NEXT = NEXT cup {A}$;
}
}
If{$|ALIGNMENTS| = |NEXT|$}{
$C_{cov} gets C_{cov} - 1$;
}
$ALIGNMENTS gets NEXT$;
}
BlankLine
KwRet{$mu$};
DecMargin{1em}
end{algorithm}
end{document}
add a comment |
Welcome to TeX.SE. From the documentation of algorithm2e you have:
documentclass[12pt]{article}
usepackage[linesnumbered,lined,boxed,commentsnumbered]{algorithm2e}
begin{document}
IncMargin{1em}
begin{algorithm}
$ALIGNMENTS gets NEXT$;
BlankLine
While{$(C_{cov} > 0) wedge (|ALIGNMENTS| > 0)$}{
$NEXT gets 0$;
ForEach{$A in ALIGNMENTS$}{
$U gets checkAlignments(mu,A,C_{cov})$;
uIf{$|U| = 1$}{
$mu gets updateProfile(mu,U)$;
}
Else{
$NEXT = NEXT cup {A}$;
}
}
If{$|ALIGNMENTS| = |NEXT|$}{
$C_{cov} gets C_{cov} - 1$;
}
$ALIGNMENTS gets NEXT$;
}
BlankLine
KwRet{$mu$};
DecMargin{1em}
end{algorithm}
end{document}
Welcome to TeX.SE. From the documentation of algorithm2e you have:
documentclass[12pt]{article}
usepackage[linesnumbered,lined,boxed,commentsnumbered]{algorithm2e}
begin{document}
IncMargin{1em}
begin{algorithm}
$ALIGNMENTS gets NEXT$;
BlankLine
While{$(C_{cov} > 0) wedge (|ALIGNMENTS| > 0)$}{
$NEXT gets 0$;
ForEach{$A in ALIGNMENTS$}{
$U gets checkAlignments(mu,A,C_{cov})$;
uIf{$|U| = 1$}{
$mu gets updateProfile(mu,U)$;
}
Else{
$NEXT = NEXT cup {A}$;
}
}
If{$|ALIGNMENTS| = |NEXT|$}{
$C_{cov} gets C_{cov} - 1$;
}
$ALIGNMENTS gets NEXT$;
}
BlankLine
KwRet{$mu$};
DecMargin{1em}
end{algorithm}
end{document}
edited Feb 25 at 12:58
answered Feb 25 at 11:47
SebastianoSebastiano
10.4k42060
10.4k42060
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%2f476579%2fhow-to-align-horizontally-line-numbers-with-package-algorithm2e%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