Lines of code counter
Is there a way to automatically count the lines of code of a TeX document? And if yes, is there a way to include that in the document?
I would like to have something like "this document is n lines of code" somewhere in the document.
counters statistics
add a comment |
Is there a way to automatically count the lines of code of a TeX document? And if yes, is there a way to include that in the document?
I would like to have something like "this document is n lines of code" somewhere in the document.
counters statistics
How is this meaningful? For example it doesn't matter if your input contains a paragraph of text in 10 lines of 80 characters each, or one line of 800 characters. Choosing one or the other is just personal preference, and/or how well your text editor works with long lines. The output will be identical either way.
– alephzero
Mar 10 at 11:51
@alephzero long lines count as one line still if there's no linebreak. I would need it for examples but it doesn't really matter in my opinion. I know similar tools exist for some programming languages so I was interested in knowing whether this existed for LaTeX too.
– Superuser27
Mar 10 at 11:54
"long lines count as one line still if there's no linebreak" - that's what I said :) If what you really want to do is number the lines in an example so you can refer to them, use thelineno
package (but that isn't the question you asked!)
– alephzero
Mar 10 at 12:14
add a comment |
Is there a way to automatically count the lines of code of a TeX document? And if yes, is there a way to include that in the document?
I would like to have something like "this document is n lines of code" somewhere in the document.
counters statistics
Is there a way to automatically count the lines of code of a TeX document? And if yes, is there a way to include that in the document?
I would like to have something like "this document is n lines of code" somewhere in the document.
counters statistics
counters statistics
asked Mar 10 at 11:25
Superuser27Superuser27
66415
66415
How is this meaningful? For example it doesn't matter if your input contains a paragraph of text in 10 lines of 80 characters each, or one line of 800 characters. Choosing one or the other is just personal preference, and/or how well your text editor works with long lines. The output will be identical either way.
– alephzero
Mar 10 at 11:51
@alephzero long lines count as one line still if there's no linebreak. I would need it for examples but it doesn't really matter in my opinion. I know similar tools exist for some programming languages so I was interested in knowing whether this existed for LaTeX too.
– Superuser27
Mar 10 at 11:54
"long lines count as one line still if there's no linebreak" - that's what I said :) If what you really want to do is number the lines in an example so you can refer to them, use thelineno
package (but that isn't the question you asked!)
– alephzero
Mar 10 at 12:14
add a comment |
How is this meaningful? For example it doesn't matter if your input contains a paragraph of text in 10 lines of 80 characters each, or one line of 800 characters. Choosing one or the other is just personal preference, and/or how well your text editor works with long lines. The output will be identical either way.
– alephzero
Mar 10 at 11:51
@alephzero long lines count as one line still if there's no linebreak. I would need it for examples but it doesn't really matter in my opinion. I know similar tools exist for some programming languages so I was interested in knowing whether this existed for LaTeX too.
– Superuser27
Mar 10 at 11:54
"long lines count as one line still if there's no linebreak" - that's what I said :) If what you really want to do is number the lines in an example so you can refer to them, use thelineno
package (but that isn't the question you asked!)
– alephzero
Mar 10 at 12:14
How is this meaningful? For example it doesn't matter if your input contains a paragraph of text in 10 lines of 80 characters each, or one line of 800 characters. Choosing one or the other is just personal preference, and/or how well your text editor works with long lines. The output will be identical either way.
– alephzero
Mar 10 at 11:51
How is this meaningful? For example it doesn't matter if your input contains a paragraph of text in 10 lines of 80 characters each, or one line of 800 characters. Choosing one or the other is just personal preference, and/or how well your text editor works with long lines. The output will be identical either way.
– alephzero
Mar 10 at 11:51
@alephzero long lines count as one line still if there's no linebreak. I would need it for examples but it doesn't really matter in my opinion. I know similar tools exist for some programming languages so I was interested in knowing whether this existed for LaTeX too.
– Superuser27
Mar 10 at 11:54
@alephzero long lines count as one line still if there's no linebreak. I would need it for examples but it doesn't really matter in my opinion. I know similar tools exist for some programming languages so I was interested in knowing whether this existed for LaTeX too.
– Superuser27
Mar 10 at 11:54
"long lines count as one line still if there's no linebreak" - that's what I said :) If what you really want to do is number the lines in an example so you can refer to them, use the
lineno
package (but that isn't the question you asked!)– alephzero
Mar 10 at 12:14
"long lines count as one line still if there's no linebreak" - that's what I said :) If what you really want to do is number the lines in an example so you can refer to them, use the
lineno
package (but that isn't the question you asked!)– alephzero
Mar 10 at 12:14
add a comment |
1 Answer
1
active
oldest
votes
TeX has an internal counter inputlineno
which is used when printing error messages, etc.
If you include theinputlineno
on the last line of your document, you should get pretty close to the number of lines in a file, though it may be off by one.
If you have multiple files in your project, you will have to add up the total number of lines yourself.
documentclass{article}
begin{document}
This is line theinputlineno
Some text
The last line is (almost!) theinputlineno
end{document}
outputs "This is line 4" and "The last line is (almost!) 8" - it didn't count the end{document}
on line 9, unsurprisingly.
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%2f478712%2flines-of-code-counter%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
TeX has an internal counter inputlineno
which is used when printing error messages, etc.
If you include theinputlineno
on the last line of your document, you should get pretty close to the number of lines in a file, though it may be off by one.
If you have multiple files in your project, you will have to add up the total number of lines yourself.
documentclass{article}
begin{document}
This is line theinputlineno
Some text
The last line is (almost!) theinputlineno
end{document}
outputs "This is line 4" and "The last line is (almost!) 8" - it didn't count the end{document}
on line 9, unsurprisingly.
add a comment |
TeX has an internal counter inputlineno
which is used when printing error messages, etc.
If you include theinputlineno
on the last line of your document, you should get pretty close to the number of lines in a file, though it may be off by one.
If you have multiple files in your project, you will have to add up the total number of lines yourself.
documentclass{article}
begin{document}
This is line theinputlineno
Some text
The last line is (almost!) theinputlineno
end{document}
outputs "This is line 4" and "The last line is (almost!) 8" - it didn't count the end{document}
on line 9, unsurprisingly.
add a comment |
TeX has an internal counter inputlineno
which is used when printing error messages, etc.
If you include theinputlineno
on the last line of your document, you should get pretty close to the number of lines in a file, though it may be off by one.
If you have multiple files in your project, you will have to add up the total number of lines yourself.
documentclass{article}
begin{document}
This is line theinputlineno
Some text
The last line is (almost!) theinputlineno
end{document}
outputs "This is line 4" and "The last line is (almost!) 8" - it didn't count the end{document}
on line 9, unsurprisingly.
TeX has an internal counter inputlineno
which is used when printing error messages, etc.
If you include theinputlineno
on the last line of your document, you should get pretty close to the number of lines in a file, though it may be off by one.
If you have multiple files in your project, you will have to add up the total number of lines yourself.
documentclass{article}
begin{document}
This is line theinputlineno
Some text
The last line is (almost!) theinputlineno
end{document}
outputs "This is line 4" and "The last line is (almost!) 8" - it didn't count the end{document}
on line 9, unsurprisingly.
answered Mar 10 at 12:11
alephzeroalephzero
1,4521513
1,4521513
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%2f478712%2flines-of-code-counter%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
How is this meaningful? For example it doesn't matter if your input contains a paragraph of text in 10 lines of 80 characters each, or one line of 800 characters. Choosing one or the other is just personal preference, and/or how well your text editor works with long lines. The output will be identical either way.
– alephzero
Mar 10 at 11:51
@alephzero long lines count as one line still if there's no linebreak. I would need it for examples but it doesn't really matter in my opinion. I know similar tools exist for some programming languages so I was interested in knowing whether this existed for LaTeX too.
– Superuser27
Mar 10 at 11:54
"long lines count as one line still if there's no linebreak" - that's what I said :) If what you really want to do is number the lines in an example so you can refer to them, use the
lineno
package (but that isn't the question you asked!)– alephzero
Mar 10 at 12:14