clean up definition file
I've got a problem with my custom definitions-file. The file has hundreds of command definitions (with newcommand
or renewcommand
; mainly shortcuts for mathematical terms, programm names,...). I used the commands in this file to write a document. But now I saw, that im not allowed to submit such additional files, so all command-definitions have to be placed in the main-file. I don't want to search for all used commands by hand and I also don't want to paste the whole definitions-file into the main-file, because I only use a small subset.
So my question is: Is there any way to get a list of the commands in my definitions-file that I use in the main-file? Or is there a way to automaticly delete all unused commands in the definitions-file?
I don't now if it is important in that case, but I compile the document with latex-dvips-ps2pdf
.
Thanks in advance! Greetings,
Freddy
macros definition
add a comment |
I've got a problem with my custom definitions-file. The file has hundreds of command definitions (with newcommand
or renewcommand
; mainly shortcuts for mathematical terms, programm names,...). I used the commands in this file to write a document. But now I saw, that im not allowed to submit such additional files, so all command-definitions have to be placed in the main-file. I don't want to search for all used commands by hand and I also don't want to paste the whole definitions-file into the main-file, because I only use a small subset.
So my question is: Is there any way to get a list of the commands in my definitions-file that I use in the main-file? Or is there a way to automaticly delete all unused commands in the definitions-file?
I don't now if it is important in that case, but I compile the document with latex-dvips-ps2pdf
.
Thanks in advance! Greetings,
Freddy
macros definition
2
I really don't think that the core of this question is opinion-based. The title may look like it, but the main question leaves little room for opinion (at least naively: an unused command is a command that is never called; of course there might be technical difficulties here, but I believe that is besides the point).
– moewe
Jan 11 at 11:16
@moewe I don't understand your comment.. What do you mean with "opinion-based question"?
– Freddy
Jan 11 at 11:24
2
The question was flagged as opinion-based (link to the review queue). (See tex.meta.stackexchange.com/q/4309/35864 and tex.stackexchange.com/help/dont-ask for a short explanation what opinion-based questions are and why they are usually considered a bad fit on this site.) I wanted to express my opinion that it is not in fact opinion based and should therefore not be closed as such.
– moewe
Jan 11 at 11:29
Thank you for this clarification. I really don't see why anyone would flag my question as opinion-based... I have a problem with latex and I ask if there is a solution to it at all, I don't even ask for the best solution from several possible ones. What is wrong with that? If I had the same problem with a bibtex-file (several hundred entries and I want a new file with the used entries), I would know easy answers with a terminal-command and with the help of programms like jabref. But for this definition file I don't know an easy answer, so I asked for help...
– Freddy
Jan 11 at 12:09
When confronting with a big preamble, I usually comment out everything, except for “everyday use” packages such asamsmath
,geometry
and some others. Then I run LaTeX and see what's missing from the error messages. It takes some time, but is guaranteed to slim the preamble to the bare minimum needed.
– egreg
Jan 11 at 12:54
add a comment |
I've got a problem with my custom definitions-file. The file has hundreds of command definitions (with newcommand
or renewcommand
; mainly shortcuts for mathematical terms, programm names,...). I used the commands in this file to write a document. But now I saw, that im not allowed to submit such additional files, so all command-definitions have to be placed in the main-file. I don't want to search for all used commands by hand and I also don't want to paste the whole definitions-file into the main-file, because I only use a small subset.
So my question is: Is there any way to get a list of the commands in my definitions-file that I use in the main-file? Or is there a way to automaticly delete all unused commands in the definitions-file?
I don't now if it is important in that case, but I compile the document with latex-dvips-ps2pdf
.
Thanks in advance! Greetings,
Freddy
macros definition
I've got a problem with my custom definitions-file. The file has hundreds of command definitions (with newcommand
or renewcommand
; mainly shortcuts for mathematical terms, programm names,...). I used the commands in this file to write a document. But now I saw, that im not allowed to submit such additional files, so all command-definitions have to be placed in the main-file. I don't want to search for all used commands by hand and I also don't want to paste the whole definitions-file into the main-file, because I only use a small subset.
So my question is: Is there any way to get a list of the commands in my definitions-file that I use in the main-file? Or is there a way to automaticly delete all unused commands in the definitions-file?
I don't now if it is important in that case, but I compile the document with latex-dvips-ps2pdf
.
Thanks in advance! Greetings,
Freddy
macros definition
macros definition
edited Jan 11 at 10:50
JouleV
2,344628
2,344628
asked Jan 11 at 10:38
FreddyFreddy
61
61
2
I really don't think that the core of this question is opinion-based. The title may look like it, but the main question leaves little room for opinion (at least naively: an unused command is a command that is never called; of course there might be technical difficulties here, but I believe that is besides the point).
– moewe
Jan 11 at 11:16
@moewe I don't understand your comment.. What do you mean with "opinion-based question"?
– Freddy
Jan 11 at 11:24
2
The question was flagged as opinion-based (link to the review queue). (See tex.meta.stackexchange.com/q/4309/35864 and tex.stackexchange.com/help/dont-ask for a short explanation what opinion-based questions are and why they are usually considered a bad fit on this site.) I wanted to express my opinion that it is not in fact opinion based and should therefore not be closed as such.
– moewe
Jan 11 at 11:29
Thank you for this clarification. I really don't see why anyone would flag my question as opinion-based... I have a problem with latex and I ask if there is a solution to it at all, I don't even ask for the best solution from several possible ones. What is wrong with that? If I had the same problem with a bibtex-file (several hundred entries and I want a new file with the used entries), I would know easy answers with a terminal-command and with the help of programms like jabref. But for this definition file I don't know an easy answer, so I asked for help...
– Freddy
Jan 11 at 12:09
When confronting with a big preamble, I usually comment out everything, except for “everyday use” packages such asamsmath
,geometry
and some others. Then I run LaTeX and see what's missing from the error messages. It takes some time, but is guaranteed to slim the preamble to the bare minimum needed.
– egreg
Jan 11 at 12:54
add a comment |
2
I really don't think that the core of this question is opinion-based. The title may look like it, but the main question leaves little room for opinion (at least naively: an unused command is a command that is never called; of course there might be technical difficulties here, but I believe that is besides the point).
– moewe
Jan 11 at 11:16
@moewe I don't understand your comment.. What do you mean with "opinion-based question"?
– Freddy
Jan 11 at 11:24
2
The question was flagged as opinion-based (link to the review queue). (See tex.meta.stackexchange.com/q/4309/35864 and tex.stackexchange.com/help/dont-ask for a short explanation what opinion-based questions are and why they are usually considered a bad fit on this site.) I wanted to express my opinion that it is not in fact opinion based and should therefore not be closed as such.
– moewe
Jan 11 at 11:29
Thank you for this clarification. I really don't see why anyone would flag my question as opinion-based... I have a problem with latex and I ask if there is a solution to it at all, I don't even ask for the best solution from several possible ones. What is wrong with that? If I had the same problem with a bibtex-file (several hundred entries and I want a new file with the used entries), I would know easy answers with a terminal-command and with the help of programms like jabref. But for this definition file I don't know an easy answer, so I asked for help...
– Freddy
Jan 11 at 12:09
When confronting with a big preamble, I usually comment out everything, except for “everyday use” packages such asamsmath
,geometry
and some others. Then I run LaTeX and see what's missing from the error messages. It takes some time, but is guaranteed to slim the preamble to the bare minimum needed.
– egreg
Jan 11 at 12:54
2
2
I really don't think that the core of this question is opinion-based. The title may look like it, but the main question leaves little room for opinion (at least naively: an unused command is a command that is never called; of course there might be technical difficulties here, but I believe that is besides the point).
– moewe
Jan 11 at 11:16
I really don't think that the core of this question is opinion-based. The title may look like it, but the main question leaves little room for opinion (at least naively: an unused command is a command that is never called; of course there might be technical difficulties here, but I believe that is besides the point).
– moewe
Jan 11 at 11:16
@moewe I don't understand your comment.. What do you mean with "opinion-based question"?
– Freddy
Jan 11 at 11:24
@moewe I don't understand your comment.. What do you mean with "opinion-based question"?
– Freddy
Jan 11 at 11:24
2
2
The question was flagged as opinion-based (link to the review queue). (See tex.meta.stackexchange.com/q/4309/35864 and tex.stackexchange.com/help/dont-ask for a short explanation what opinion-based questions are and why they are usually considered a bad fit on this site.) I wanted to express my opinion that it is not in fact opinion based and should therefore not be closed as such.
– moewe
Jan 11 at 11:29
The question was flagged as opinion-based (link to the review queue). (See tex.meta.stackexchange.com/q/4309/35864 and tex.stackexchange.com/help/dont-ask for a short explanation what opinion-based questions are and why they are usually considered a bad fit on this site.) I wanted to express my opinion that it is not in fact opinion based and should therefore not be closed as such.
– moewe
Jan 11 at 11:29
Thank you for this clarification. I really don't see why anyone would flag my question as opinion-based... I have a problem with latex and I ask if there is a solution to it at all, I don't even ask for the best solution from several possible ones. What is wrong with that? If I had the same problem with a bibtex-file (several hundred entries and I want a new file with the used entries), I would know easy answers with a terminal-command and with the help of programms like jabref. But for this definition file I don't know an easy answer, so I asked for help...
– Freddy
Jan 11 at 12:09
Thank you for this clarification. I really don't see why anyone would flag my question as opinion-based... I have a problem with latex and I ask if there is a solution to it at all, I don't even ask for the best solution from several possible ones. What is wrong with that? If I had the same problem with a bibtex-file (several hundred entries and I want a new file with the used entries), I would know easy answers with a terminal-command and with the help of programms like jabref. But for this definition file I don't know an easy answer, so I asked for help...
– Freddy
Jan 11 at 12:09
When confronting with a big preamble, I usually comment out everything, except for “everyday use” packages such as
amsmath
, geometry
and some others. Then I run LaTeX and see what's missing from the error messages. It takes some time, but is guaranteed to slim the preamble to the bare minimum needed.– egreg
Jan 11 at 12:54
When confronting with a big preamble, I usually comment out everything, except for “everyday use” packages such as
amsmath
, geometry
and some others. Then I run LaTeX and see what's missing from the error messages. It takes some time, but is guaranteed to slim the preamble to the bare minimum needed.– egreg
Jan 11 at 12:54
add a comment |
1 Answer
1
active
oldest
votes
If you really want something automatic, I've found this (very fragile and temporary) solution: you have to add some lines to your file of definitions and then you have to compile your document. All the commands defined in your definition file will "do nothing" in your document, but a list of the ones that have been used throughout the document will appear at the end of it.
Here you can see how it works:
documentclass{article}
%input{file.def}
% Content of definition file:
% ***************************
% Let's redefine newcommand
makeatletter
letoldnewcommandnewcommand
letoldrenewcommandrenewcommand
gdefusedcommands{parbigskipnoindent Used commands:par}
defnewcommand#1{%
@namedef{string#1}{string #1}%
def#1{%
g@addto@macrousedcommands{ttfamily@nameuse{string#1}par}%
def#1{}%
}%
providecommand@unuseful
}
letrenewcommandnewcommand
% Now the definitions you had before:
newcommandlorem{...}
newcommandipsum[1]{#1 ...}
newcommanddolor{...}
newcommand{sit}{...}
newcommandamet{....}
% Some other adjustments:
letnewcommandoldnewcommand
letrenewcommandoldrenewcommand
AtEndDocument{usedcommands}
makeatother
% ***************************
begin{document}
Random text, loremloremsitipsum
ipsum
sit
end{document}
(I assumed you've never use newcommand*
, otherwise there would be some other work to do...)
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%2f469676%2fclean-up-definition-file%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
If you really want something automatic, I've found this (very fragile and temporary) solution: you have to add some lines to your file of definitions and then you have to compile your document. All the commands defined in your definition file will "do nothing" in your document, but a list of the ones that have been used throughout the document will appear at the end of it.
Here you can see how it works:
documentclass{article}
%input{file.def}
% Content of definition file:
% ***************************
% Let's redefine newcommand
makeatletter
letoldnewcommandnewcommand
letoldrenewcommandrenewcommand
gdefusedcommands{parbigskipnoindent Used commands:par}
defnewcommand#1{%
@namedef{string#1}{string #1}%
def#1{%
g@addto@macrousedcommands{ttfamily@nameuse{string#1}par}%
def#1{}%
}%
providecommand@unuseful
}
letrenewcommandnewcommand
% Now the definitions you had before:
newcommandlorem{...}
newcommandipsum[1]{#1 ...}
newcommanddolor{...}
newcommand{sit}{...}
newcommandamet{....}
% Some other adjustments:
letnewcommandoldnewcommand
letrenewcommandoldrenewcommand
AtEndDocument{usedcommands}
makeatother
% ***************************
begin{document}
Random text, loremloremsitipsum
ipsum
sit
end{document}
(I assumed you've never use newcommand*
, otherwise there would be some other work to do...)
add a comment |
If you really want something automatic, I've found this (very fragile and temporary) solution: you have to add some lines to your file of definitions and then you have to compile your document. All the commands defined in your definition file will "do nothing" in your document, but a list of the ones that have been used throughout the document will appear at the end of it.
Here you can see how it works:
documentclass{article}
%input{file.def}
% Content of definition file:
% ***************************
% Let's redefine newcommand
makeatletter
letoldnewcommandnewcommand
letoldrenewcommandrenewcommand
gdefusedcommands{parbigskipnoindent Used commands:par}
defnewcommand#1{%
@namedef{string#1}{string #1}%
def#1{%
g@addto@macrousedcommands{ttfamily@nameuse{string#1}par}%
def#1{}%
}%
providecommand@unuseful
}
letrenewcommandnewcommand
% Now the definitions you had before:
newcommandlorem{...}
newcommandipsum[1]{#1 ...}
newcommanddolor{...}
newcommand{sit}{...}
newcommandamet{....}
% Some other adjustments:
letnewcommandoldnewcommand
letrenewcommandoldrenewcommand
AtEndDocument{usedcommands}
makeatother
% ***************************
begin{document}
Random text, loremloremsitipsum
ipsum
sit
end{document}
(I assumed you've never use newcommand*
, otherwise there would be some other work to do...)
add a comment |
If you really want something automatic, I've found this (very fragile and temporary) solution: you have to add some lines to your file of definitions and then you have to compile your document. All the commands defined in your definition file will "do nothing" in your document, but a list of the ones that have been used throughout the document will appear at the end of it.
Here you can see how it works:
documentclass{article}
%input{file.def}
% Content of definition file:
% ***************************
% Let's redefine newcommand
makeatletter
letoldnewcommandnewcommand
letoldrenewcommandrenewcommand
gdefusedcommands{parbigskipnoindent Used commands:par}
defnewcommand#1{%
@namedef{string#1}{string #1}%
def#1{%
g@addto@macrousedcommands{ttfamily@nameuse{string#1}par}%
def#1{}%
}%
providecommand@unuseful
}
letrenewcommandnewcommand
% Now the definitions you had before:
newcommandlorem{...}
newcommandipsum[1]{#1 ...}
newcommanddolor{...}
newcommand{sit}{...}
newcommandamet{....}
% Some other adjustments:
letnewcommandoldnewcommand
letrenewcommandoldrenewcommand
AtEndDocument{usedcommands}
makeatother
% ***************************
begin{document}
Random text, loremloremsitipsum
ipsum
sit
end{document}
(I assumed you've never use newcommand*
, otherwise there would be some other work to do...)
If you really want something automatic, I've found this (very fragile and temporary) solution: you have to add some lines to your file of definitions and then you have to compile your document. All the commands defined in your definition file will "do nothing" in your document, but a list of the ones that have been used throughout the document will appear at the end of it.
Here you can see how it works:
documentclass{article}
%input{file.def}
% Content of definition file:
% ***************************
% Let's redefine newcommand
makeatletter
letoldnewcommandnewcommand
letoldrenewcommandrenewcommand
gdefusedcommands{parbigskipnoindent Used commands:par}
defnewcommand#1{%
@namedef{string#1}{string #1}%
def#1{%
g@addto@macrousedcommands{ttfamily@nameuse{string#1}par}%
def#1{}%
}%
providecommand@unuseful
}
letrenewcommandnewcommand
% Now the definitions you had before:
newcommandlorem{...}
newcommandipsum[1]{#1 ...}
newcommanddolor{...}
newcommand{sit}{...}
newcommandamet{....}
% Some other adjustments:
letnewcommandoldnewcommand
letrenewcommandoldrenewcommand
AtEndDocument{usedcommands}
makeatother
% ***************************
begin{document}
Random text, loremloremsitipsum
ipsum
sit
end{document}
(I assumed you've never use newcommand*
, otherwise there would be some other work to do...)
edited Jan 11 at 16:59
answered Jan 11 at 15:45
zetaeffezetaeffe
3165
3165
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%2f469676%2fclean-up-definition-file%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
2
I really don't think that the core of this question is opinion-based. The title may look like it, but the main question leaves little room for opinion (at least naively: an unused command is a command that is never called; of course there might be technical difficulties here, but I believe that is besides the point).
– moewe
Jan 11 at 11:16
@moewe I don't understand your comment.. What do you mean with "opinion-based question"?
– Freddy
Jan 11 at 11:24
2
The question was flagged as opinion-based (link to the review queue). (See tex.meta.stackexchange.com/q/4309/35864 and tex.stackexchange.com/help/dont-ask for a short explanation what opinion-based questions are and why they are usually considered a bad fit on this site.) I wanted to express my opinion that it is not in fact opinion based and should therefore not be closed as such.
– moewe
Jan 11 at 11:29
Thank you for this clarification. I really don't see why anyone would flag my question as opinion-based... I have a problem with latex and I ask if there is a solution to it at all, I don't even ask for the best solution from several possible ones. What is wrong with that? If I had the same problem with a bibtex-file (several hundred entries and I want a new file with the used entries), I would know easy answers with a terminal-command and with the help of programms like jabref. But for this definition file I don't know an easy answer, so I asked for help...
– Freddy
Jan 11 at 12:09
When confronting with a big preamble, I usually comment out everything, except for “everyday use” packages such as
amsmath
,geometry
and some others. Then I run LaTeX and see what's missing from the error messages. It takes some time, but is guaranteed to slim the preamble to the bare minimum needed.– egreg
Jan 11 at 12:54