Configuring auto-completion with TeXstudio
up vote
7
down vote
favorite
TeXstudio does a pretty good job with autocompletion. For example, when I type eqref{, it already comes with suggestions, see the example below.

However, suppose that I don't want to use eqref but a customized command using newcommand (I do this so that I can quickly switch to different styles, e.g., some for journals/conferences "Eq. (1)" is needed, whereas sometimes "(1)" suffices). In this case, TeXstudio does not do the auto-completion, see the example below.

Is it possible to configure TeXstudio such that it does the auto-completion for custom commands that require a reference?
Note that one option is to redefine eqref using renewcommand, but I'm looking for another way so that I can use if for many more commands, not just for eqref.
Here is my MWE:
documentclass{article}
usepackage{amsmath}
newcommand{alternative}[1]{Eq.~(ref{#1})}
begin{document}
begin{equation}
label{eq:emc2}
E = mc^2
end{equation}
I can refer to the equation using eqref{eq:emc2} and using alternative{eq:emc2}.
end{document}
texstudio auto-completion
add a comment |
up vote
7
down vote
favorite
TeXstudio does a pretty good job with autocompletion. For example, when I type eqref{, it already comes with suggestions, see the example below.

However, suppose that I don't want to use eqref but a customized command using newcommand (I do this so that I can quickly switch to different styles, e.g., some for journals/conferences "Eq. (1)" is needed, whereas sometimes "(1)" suffices). In this case, TeXstudio does not do the auto-completion, see the example below.

Is it possible to configure TeXstudio such that it does the auto-completion for custom commands that require a reference?
Note that one option is to redefine eqref using renewcommand, but I'm looking for another way so that I can use if for many more commands, not just for eqref.
Here is my MWE:
documentclass{article}
usepackage{amsmath}
newcommand{alternative}[1]{Eq.~(ref{#1})}
begin{document}
begin{equation}
label{eq:emc2}
E = mc^2
end{equation}
I can refer to the equation using eqref{eq:emc2} and using alternative{eq:emc2}.
end{document}
texstudio auto-completion
add a comment |
up vote
7
down vote
favorite
up vote
7
down vote
favorite
TeXstudio does a pretty good job with autocompletion. For example, when I type eqref{, it already comes with suggestions, see the example below.

However, suppose that I don't want to use eqref but a customized command using newcommand (I do this so that I can quickly switch to different styles, e.g., some for journals/conferences "Eq. (1)" is needed, whereas sometimes "(1)" suffices). In this case, TeXstudio does not do the auto-completion, see the example below.

Is it possible to configure TeXstudio such that it does the auto-completion for custom commands that require a reference?
Note that one option is to redefine eqref using renewcommand, but I'm looking for another way so that I can use if for many more commands, not just for eqref.
Here is my MWE:
documentclass{article}
usepackage{amsmath}
newcommand{alternative}[1]{Eq.~(ref{#1})}
begin{document}
begin{equation}
label{eq:emc2}
E = mc^2
end{equation}
I can refer to the equation using eqref{eq:emc2} and using alternative{eq:emc2}.
end{document}
texstudio auto-completion
TeXstudio does a pretty good job with autocompletion. For example, when I type eqref{, it already comes with suggestions, see the example below.

However, suppose that I don't want to use eqref but a customized command using newcommand (I do this so that I can quickly switch to different styles, e.g., some for journals/conferences "Eq. (1)" is needed, whereas sometimes "(1)" suffices). In this case, TeXstudio does not do the auto-completion, see the example below.

Is it possible to configure TeXstudio such that it does the auto-completion for custom commands that require a reference?
Note that one option is to redefine eqref using renewcommand, but I'm looking for another way so that I can use if for many more commands, not just for eqref.
Here is my MWE:
documentclass{article}
usepackage{amsmath}
newcommand{alternative}[1]{Eq.~(ref{#1})}
begin{document}
begin{equation}
label{eq:emc2}
E = mc^2
end{equation}
I can refer to the equation using eqref{eq:emc2} and using alternative{eq:emc2}.
end{document}
texstudio auto-completion
texstudio auto-completion
edited Feb 8 at 12:03
asked Feb 8 at 10:04
EdG
23219
23219
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
12
down vote
accepted
For that, you will have to make use of a custom .cwl file (which, afaik, requires a recent version of TeXstudio).
Create a file, let's say mycwl.cwl, in either %appdata%texstudiocompletionuser or .config/texstudio/completion/user according to your system.
In it, place the following line:
alternative{label}#r
and save it. Technically, you can put anything meaningful in the argument, but some terms are reserved and have special meaning. And, as you wish TeXstudio to recognize a label there, you require one of those, namely label. The comment at the end of the line tells TeXstudio what kind of command yours is. #r stands for this command declares a reference like "ref{key}". For further commands, just add a new line to your mycwl.cwl.
Then, in TeXstudio, go to Options -> Configure TeXstudio -> Completion and check mycwl.cwl on the list. And that's about it.

For more details on customizing autocompletion with cwl files, check the TeXstudio manual, section "4.13 Description of the cwl format".
A tip: If the manual seems complicated, and you'd like to emulate the behavior of some command's autocompletion you like, you might want to download the sourcecode tarball at http://texstudio.sourceforge.net/, unpack it and look at the built-in cwl files in the "completion" folder. From there, you can proceed by means of examples of your commands of interest.
Wow, that would have taken me hours to figure this out (if I ever succeeded). Thanks, it works like a charm!
– EdG
Feb 8 at 11:54
1
@EdG, glad to hear. Btw, it would have been kind of you if you had posted your MWE as code, rather than image, so that you did not leave to others the work of retyping. I still think it is a good idea for you to add it to the question.
– gusbrs
Feb 8 at 12:00
Oh oops, that's stupid from me. Will add it now! Thanks for the feedback.
– EdG
Feb 8 at 12:02
@COTO, thanks for the edit, I indeed missed the typo.
– gusbrs
Feb 12 at 15:31
off topic: Do you know abouteqref{}which inserts( )automatically?
– Sigur
Feb 12 at 15:37
|
show 6 more comments
up vote
7
down vote
I suggest to use the cleveref package instead of manually defining commands for all possible types of labels.
cleverefwill automatically insert the appropriate string based on the type of label you are referring totexstudio automatically suggest possible labels


documentclass{article}
usepackage{amsmath}
usepackage[capitalise]{cleveref}
begin{document}
begin{equation}
label{eq:emc2}
E = mc^2
end{equation}
I can refer to the equation using eqref{eq:emc2} and using cref{eq:emc2}.
end{document}
I took the question in abstract form, but that is certainly good advice! (+1)
– gusbrs
Feb 8 at 12:48
Btw, you see I finally updated my TS, stimulated by an answer of yours not long ago. :)
– gusbrs
Feb 8 at 12:50
@gusbrs :) I wish you a lot of fun with your updated TS! I am eagerly waiting for version 2.12.8 because of this commit: github.com/texstudio-org/texstudio/commit/…
– samcarter
Feb 8 at 13:36
@samcarter Thanks for your answer. Though it is not an exact answer to my question, it's a very good advice (+1). I did not know of cleverref, but now I do :)
– EdG
Feb 8 at 13:40
hahaha! Indeed, the only conceivable reason why this was not part of TS since version 0.1 beta is thattikzduckswas not available then. :)
– gusbrs
Feb 8 at 13:42
|
show 6 more comments
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
12
down vote
accepted
For that, you will have to make use of a custom .cwl file (which, afaik, requires a recent version of TeXstudio).
Create a file, let's say mycwl.cwl, in either %appdata%texstudiocompletionuser or .config/texstudio/completion/user according to your system.
In it, place the following line:
alternative{label}#r
and save it. Technically, you can put anything meaningful in the argument, but some terms are reserved and have special meaning. And, as you wish TeXstudio to recognize a label there, you require one of those, namely label. The comment at the end of the line tells TeXstudio what kind of command yours is. #r stands for this command declares a reference like "ref{key}". For further commands, just add a new line to your mycwl.cwl.
Then, in TeXstudio, go to Options -> Configure TeXstudio -> Completion and check mycwl.cwl on the list. And that's about it.

For more details on customizing autocompletion with cwl files, check the TeXstudio manual, section "4.13 Description of the cwl format".
A tip: If the manual seems complicated, and you'd like to emulate the behavior of some command's autocompletion you like, you might want to download the sourcecode tarball at http://texstudio.sourceforge.net/, unpack it and look at the built-in cwl files in the "completion" folder. From there, you can proceed by means of examples of your commands of interest.
Wow, that would have taken me hours to figure this out (if I ever succeeded). Thanks, it works like a charm!
– EdG
Feb 8 at 11:54
1
@EdG, glad to hear. Btw, it would have been kind of you if you had posted your MWE as code, rather than image, so that you did not leave to others the work of retyping. I still think it is a good idea for you to add it to the question.
– gusbrs
Feb 8 at 12:00
Oh oops, that's stupid from me. Will add it now! Thanks for the feedback.
– EdG
Feb 8 at 12:02
@COTO, thanks for the edit, I indeed missed the typo.
– gusbrs
Feb 12 at 15:31
off topic: Do you know abouteqref{}which inserts( )automatically?
– Sigur
Feb 12 at 15:37
|
show 6 more comments
up vote
12
down vote
accepted
For that, you will have to make use of a custom .cwl file (which, afaik, requires a recent version of TeXstudio).
Create a file, let's say mycwl.cwl, in either %appdata%texstudiocompletionuser or .config/texstudio/completion/user according to your system.
In it, place the following line:
alternative{label}#r
and save it. Technically, you can put anything meaningful in the argument, but some terms are reserved and have special meaning. And, as you wish TeXstudio to recognize a label there, you require one of those, namely label. The comment at the end of the line tells TeXstudio what kind of command yours is. #r stands for this command declares a reference like "ref{key}". For further commands, just add a new line to your mycwl.cwl.
Then, in TeXstudio, go to Options -> Configure TeXstudio -> Completion and check mycwl.cwl on the list. And that's about it.

For more details on customizing autocompletion with cwl files, check the TeXstudio manual, section "4.13 Description of the cwl format".
A tip: If the manual seems complicated, and you'd like to emulate the behavior of some command's autocompletion you like, you might want to download the sourcecode tarball at http://texstudio.sourceforge.net/, unpack it and look at the built-in cwl files in the "completion" folder. From there, you can proceed by means of examples of your commands of interest.
Wow, that would have taken me hours to figure this out (if I ever succeeded). Thanks, it works like a charm!
– EdG
Feb 8 at 11:54
1
@EdG, glad to hear. Btw, it would have been kind of you if you had posted your MWE as code, rather than image, so that you did not leave to others the work of retyping. I still think it is a good idea for you to add it to the question.
– gusbrs
Feb 8 at 12:00
Oh oops, that's stupid from me. Will add it now! Thanks for the feedback.
– EdG
Feb 8 at 12:02
@COTO, thanks for the edit, I indeed missed the typo.
– gusbrs
Feb 12 at 15:31
off topic: Do you know abouteqref{}which inserts( )automatically?
– Sigur
Feb 12 at 15:37
|
show 6 more comments
up vote
12
down vote
accepted
up vote
12
down vote
accepted
For that, you will have to make use of a custom .cwl file (which, afaik, requires a recent version of TeXstudio).
Create a file, let's say mycwl.cwl, in either %appdata%texstudiocompletionuser or .config/texstudio/completion/user according to your system.
In it, place the following line:
alternative{label}#r
and save it. Technically, you can put anything meaningful in the argument, but some terms are reserved and have special meaning. And, as you wish TeXstudio to recognize a label there, you require one of those, namely label. The comment at the end of the line tells TeXstudio what kind of command yours is. #r stands for this command declares a reference like "ref{key}". For further commands, just add a new line to your mycwl.cwl.
Then, in TeXstudio, go to Options -> Configure TeXstudio -> Completion and check mycwl.cwl on the list. And that's about it.

For more details on customizing autocompletion with cwl files, check the TeXstudio manual, section "4.13 Description of the cwl format".
A tip: If the manual seems complicated, and you'd like to emulate the behavior of some command's autocompletion you like, you might want to download the sourcecode tarball at http://texstudio.sourceforge.net/, unpack it and look at the built-in cwl files in the "completion" folder. From there, you can proceed by means of examples of your commands of interest.
For that, you will have to make use of a custom .cwl file (which, afaik, requires a recent version of TeXstudio).
Create a file, let's say mycwl.cwl, in either %appdata%texstudiocompletionuser or .config/texstudio/completion/user according to your system.
In it, place the following line:
alternative{label}#r
and save it. Technically, you can put anything meaningful in the argument, but some terms are reserved and have special meaning. And, as you wish TeXstudio to recognize a label there, you require one of those, namely label. The comment at the end of the line tells TeXstudio what kind of command yours is. #r stands for this command declares a reference like "ref{key}". For further commands, just add a new line to your mycwl.cwl.
Then, in TeXstudio, go to Options -> Configure TeXstudio -> Completion and check mycwl.cwl on the list. And that's about it.

For more details on customizing autocompletion with cwl files, check the TeXstudio manual, section "4.13 Description of the cwl format".
A tip: If the manual seems complicated, and you'd like to emulate the behavior of some command's autocompletion you like, you might want to download the sourcecode tarball at http://texstudio.sourceforge.net/, unpack it and look at the built-in cwl files in the "completion" folder. From there, you can proceed by means of examples of your commands of interest.
edited Feb 12 at 16:04
answered Feb 8 at 11:22
gusbrs
6,0892838
6,0892838
Wow, that would have taken me hours to figure this out (if I ever succeeded). Thanks, it works like a charm!
– EdG
Feb 8 at 11:54
1
@EdG, glad to hear. Btw, it would have been kind of you if you had posted your MWE as code, rather than image, so that you did not leave to others the work of retyping. I still think it is a good idea for you to add it to the question.
– gusbrs
Feb 8 at 12:00
Oh oops, that's stupid from me. Will add it now! Thanks for the feedback.
– EdG
Feb 8 at 12:02
@COTO, thanks for the edit, I indeed missed the typo.
– gusbrs
Feb 12 at 15:31
off topic: Do you know abouteqref{}which inserts( )automatically?
– Sigur
Feb 12 at 15:37
|
show 6 more comments
Wow, that would have taken me hours to figure this out (if I ever succeeded). Thanks, it works like a charm!
– EdG
Feb 8 at 11:54
1
@EdG, glad to hear. Btw, it would have been kind of you if you had posted your MWE as code, rather than image, so that you did not leave to others the work of retyping. I still think it is a good idea for you to add it to the question.
– gusbrs
Feb 8 at 12:00
Oh oops, that's stupid from me. Will add it now! Thanks for the feedback.
– EdG
Feb 8 at 12:02
@COTO, thanks for the edit, I indeed missed the typo.
– gusbrs
Feb 12 at 15:31
off topic: Do you know abouteqref{}which inserts( )automatically?
– Sigur
Feb 12 at 15:37
Wow, that would have taken me hours to figure this out (if I ever succeeded). Thanks, it works like a charm!
– EdG
Feb 8 at 11:54
Wow, that would have taken me hours to figure this out (if I ever succeeded). Thanks, it works like a charm!
– EdG
Feb 8 at 11:54
1
1
@EdG, glad to hear. Btw, it would have been kind of you if you had posted your MWE as code, rather than image, so that you did not leave to others the work of retyping. I still think it is a good idea for you to add it to the question.
– gusbrs
Feb 8 at 12:00
@EdG, glad to hear. Btw, it would have been kind of you if you had posted your MWE as code, rather than image, so that you did not leave to others the work of retyping. I still think it is a good idea for you to add it to the question.
– gusbrs
Feb 8 at 12:00
Oh oops, that's stupid from me. Will add it now! Thanks for the feedback.
– EdG
Feb 8 at 12:02
Oh oops, that's stupid from me. Will add it now! Thanks for the feedback.
– EdG
Feb 8 at 12:02
@COTO, thanks for the edit, I indeed missed the typo.
– gusbrs
Feb 12 at 15:31
@COTO, thanks for the edit, I indeed missed the typo.
– gusbrs
Feb 12 at 15:31
off topic: Do you know about
eqref{} which inserts ( ) automatically?– Sigur
Feb 12 at 15:37
off topic: Do you know about
eqref{} which inserts ( ) automatically?– Sigur
Feb 12 at 15:37
|
show 6 more comments
up vote
7
down vote
I suggest to use the cleveref package instead of manually defining commands for all possible types of labels.
cleverefwill automatically insert the appropriate string based on the type of label you are referring totexstudio automatically suggest possible labels


documentclass{article}
usepackage{amsmath}
usepackage[capitalise]{cleveref}
begin{document}
begin{equation}
label{eq:emc2}
E = mc^2
end{equation}
I can refer to the equation using eqref{eq:emc2} and using cref{eq:emc2}.
end{document}
I took the question in abstract form, but that is certainly good advice! (+1)
– gusbrs
Feb 8 at 12:48
Btw, you see I finally updated my TS, stimulated by an answer of yours not long ago. :)
– gusbrs
Feb 8 at 12:50
@gusbrs :) I wish you a lot of fun with your updated TS! I am eagerly waiting for version 2.12.8 because of this commit: github.com/texstudio-org/texstudio/commit/…
– samcarter
Feb 8 at 13:36
@samcarter Thanks for your answer. Though it is not an exact answer to my question, it's a very good advice (+1). I did not know of cleverref, but now I do :)
– EdG
Feb 8 at 13:40
hahaha! Indeed, the only conceivable reason why this was not part of TS since version 0.1 beta is thattikzduckswas not available then. :)
– gusbrs
Feb 8 at 13:42
|
show 6 more comments
up vote
7
down vote
I suggest to use the cleveref package instead of manually defining commands for all possible types of labels.
cleverefwill automatically insert the appropriate string based on the type of label you are referring totexstudio automatically suggest possible labels


documentclass{article}
usepackage{amsmath}
usepackage[capitalise]{cleveref}
begin{document}
begin{equation}
label{eq:emc2}
E = mc^2
end{equation}
I can refer to the equation using eqref{eq:emc2} and using cref{eq:emc2}.
end{document}
I took the question in abstract form, but that is certainly good advice! (+1)
– gusbrs
Feb 8 at 12:48
Btw, you see I finally updated my TS, stimulated by an answer of yours not long ago. :)
– gusbrs
Feb 8 at 12:50
@gusbrs :) I wish you a lot of fun with your updated TS! I am eagerly waiting for version 2.12.8 because of this commit: github.com/texstudio-org/texstudio/commit/…
– samcarter
Feb 8 at 13:36
@samcarter Thanks for your answer. Though it is not an exact answer to my question, it's a very good advice (+1). I did not know of cleverref, but now I do :)
– EdG
Feb 8 at 13:40
hahaha! Indeed, the only conceivable reason why this was not part of TS since version 0.1 beta is thattikzduckswas not available then. :)
– gusbrs
Feb 8 at 13:42
|
show 6 more comments
up vote
7
down vote
up vote
7
down vote
I suggest to use the cleveref package instead of manually defining commands for all possible types of labels.
cleverefwill automatically insert the appropriate string based on the type of label you are referring totexstudio automatically suggest possible labels


documentclass{article}
usepackage{amsmath}
usepackage[capitalise]{cleveref}
begin{document}
begin{equation}
label{eq:emc2}
E = mc^2
end{equation}
I can refer to the equation using eqref{eq:emc2} and using cref{eq:emc2}.
end{document}
I suggest to use the cleveref package instead of manually defining commands for all possible types of labels.
cleverefwill automatically insert the appropriate string based on the type of label you are referring totexstudio automatically suggest possible labels


documentclass{article}
usepackage{amsmath}
usepackage[capitalise]{cleveref}
begin{document}
begin{equation}
label{eq:emc2}
E = mc^2
end{equation}
I can refer to the equation using eqref{eq:emc2} and using cref{eq:emc2}.
end{document}
answered Feb 8 at 12:38
samcarter
82.1k793262
82.1k793262
I took the question in abstract form, but that is certainly good advice! (+1)
– gusbrs
Feb 8 at 12:48
Btw, you see I finally updated my TS, stimulated by an answer of yours not long ago. :)
– gusbrs
Feb 8 at 12:50
@gusbrs :) I wish you a lot of fun with your updated TS! I am eagerly waiting for version 2.12.8 because of this commit: github.com/texstudio-org/texstudio/commit/…
– samcarter
Feb 8 at 13:36
@samcarter Thanks for your answer. Though it is not an exact answer to my question, it's a very good advice (+1). I did not know of cleverref, but now I do :)
– EdG
Feb 8 at 13:40
hahaha! Indeed, the only conceivable reason why this was not part of TS since version 0.1 beta is thattikzduckswas not available then. :)
– gusbrs
Feb 8 at 13:42
|
show 6 more comments
I took the question in abstract form, but that is certainly good advice! (+1)
– gusbrs
Feb 8 at 12:48
Btw, you see I finally updated my TS, stimulated by an answer of yours not long ago. :)
– gusbrs
Feb 8 at 12:50
@gusbrs :) I wish you a lot of fun with your updated TS! I am eagerly waiting for version 2.12.8 because of this commit: github.com/texstudio-org/texstudio/commit/…
– samcarter
Feb 8 at 13:36
@samcarter Thanks for your answer. Though it is not an exact answer to my question, it's a very good advice (+1). I did not know of cleverref, but now I do :)
– EdG
Feb 8 at 13:40
hahaha! Indeed, the only conceivable reason why this was not part of TS since version 0.1 beta is thattikzduckswas not available then. :)
– gusbrs
Feb 8 at 13:42
I took the question in abstract form, but that is certainly good advice! (+1)
– gusbrs
Feb 8 at 12:48
I took the question in abstract form, but that is certainly good advice! (+1)
– gusbrs
Feb 8 at 12:48
Btw, you see I finally updated my TS, stimulated by an answer of yours not long ago. :)
– gusbrs
Feb 8 at 12:50
Btw, you see I finally updated my TS, stimulated by an answer of yours not long ago. :)
– gusbrs
Feb 8 at 12:50
@gusbrs :) I wish you a lot of fun with your updated TS! I am eagerly waiting for version 2.12.8 because of this commit: github.com/texstudio-org/texstudio/commit/…
– samcarter
Feb 8 at 13:36
@gusbrs :) I wish you a lot of fun with your updated TS! I am eagerly waiting for version 2.12.8 because of this commit: github.com/texstudio-org/texstudio/commit/…
– samcarter
Feb 8 at 13:36
@samcarter Thanks for your answer. Though it is not an exact answer to my question, it's a very good advice (+1). I did not know of cleverref, but now I do :)
– EdG
Feb 8 at 13:40
@samcarter Thanks for your answer. Though it is not an exact answer to my question, it's a very good advice (+1). I did not know of cleverref, but now I do :)
– EdG
Feb 8 at 13:40
hahaha! Indeed, the only conceivable reason why this was not part of TS since version 0.1 beta is that
tikzducks was not available then. :)– gusbrs
Feb 8 at 13:42
hahaha! Indeed, the only conceivable reason why this was not part of TS since version 0.1 beta is that
tikzducks was not available then. :)– gusbrs
Feb 8 at 13:42
|
show 6 more comments
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%2f414281%2fconfiguring-auto-completion-with-texstudio%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