How to make cleveref cross-references match a modified equation label style?
I know that eqref exactly matches the style of the reference to the style of the equation label. However, I prefer to use cref from the cleveref package because (1) it allows me to place the word Equation before the number and because (2) it allows me type cref{eq1,eq2} quite comfortably. Further, following this question, I'm redefining the style of the equation number delimiters. Unluckily, such a change is not captured by the cleveref package.
Here goes a MWE:
documentclass{article}
usepackage{amsmath}
usepackage[capitalise,noabbrev,]{cleveref}
makeatletter
deftagform@#1{maketag@@@{[ignorespaces#1unskip@@italiccorr]}}
makeatother
begin{document}
cref{eq1} is fancy
begin{equation}label{eq1}
a = b
end{equation}
end{document}
This produces:

Then, my question is: how can I get the round parentheses to become square brackets?
Thank you all for your time.
equations cross-referencing cleveref
add a comment |
I know that eqref exactly matches the style of the reference to the style of the equation label. However, I prefer to use cref from the cleveref package because (1) it allows me to place the word Equation before the number and because (2) it allows me type cref{eq1,eq2} quite comfortably. Further, following this question, I'm redefining the style of the equation number delimiters. Unluckily, such a change is not captured by the cleveref package.
Here goes a MWE:
documentclass{article}
usepackage{amsmath}
usepackage[capitalise,noabbrev,]{cleveref}
makeatletter
deftagform@#1{maketag@@@{[ignorespaces#1unskip@@italiccorr]}}
makeatother
begin{document}
cref{eq1} is fancy
begin{equation}label{eq1}
a = b
end{equation}
end{document}
This produces:

Then, my question is: how can I get the round parentheses to become square brackets?
Thank you all for your time.
equations cross-referencing cleveref
1
See themathtoolspackage for itsnewtagformmacro as well in order to simplify such styles of equation tags
– Christian Hupfer
Nov 9 '17 at 12:13
1
Do you mean thatmathtoolsprovides easier ways to do what I'm doing?
– Héctor
Nov 9 '17 at 12:14
1
Regarding the style of tagsmathtoolsis helping you definitely, but I think thecrefissue still persists, however.mathtoolsloadsamsmath(and extends it) so you will be able to use everything you already applied fromamsmath
– Christian Hupfer
Nov 9 '17 at 12:15
add a comment |
I know that eqref exactly matches the style of the reference to the style of the equation label. However, I prefer to use cref from the cleveref package because (1) it allows me to place the word Equation before the number and because (2) it allows me type cref{eq1,eq2} quite comfortably. Further, following this question, I'm redefining the style of the equation number delimiters. Unluckily, such a change is not captured by the cleveref package.
Here goes a MWE:
documentclass{article}
usepackage{amsmath}
usepackage[capitalise,noabbrev,]{cleveref}
makeatletter
deftagform@#1{maketag@@@{[ignorespaces#1unskip@@italiccorr]}}
makeatother
begin{document}
cref{eq1} is fancy
begin{equation}label{eq1}
a = b
end{equation}
end{document}
This produces:

Then, my question is: how can I get the round parentheses to become square brackets?
Thank you all for your time.
equations cross-referencing cleveref
I know that eqref exactly matches the style of the reference to the style of the equation label. However, I prefer to use cref from the cleveref package because (1) it allows me to place the word Equation before the number and because (2) it allows me type cref{eq1,eq2} quite comfortably. Further, following this question, I'm redefining the style of the equation number delimiters. Unluckily, such a change is not captured by the cleveref package.
Here goes a MWE:
documentclass{article}
usepackage{amsmath}
usepackage[capitalise,noabbrev,]{cleveref}
makeatletter
deftagform@#1{maketag@@@{[ignorespaces#1unskip@@italiccorr]}}
makeatother
begin{document}
cref{eq1} is fancy
begin{equation}label{eq1}
a = b
end{equation}
end{document}
This produces:

Then, my question is: how can I get the round parentheses to become square brackets?
Thank you all for your time.
equations cross-referencing cleveref
equations cross-referencing cleveref
edited Nov 9 '17 at 18:18
Héctor
asked Nov 9 '17 at 12:01
HéctorHéctor
809417
809417
1
See themathtoolspackage for itsnewtagformmacro as well in order to simplify such styles of equation tags
– Christian Hupfer
Nov 9 '17 at 12:13
1
Do you mean thatmathtoolsprovides easier ways to do what I'm doing?
– Héctor
Nov 9 '17 at 12:14
1
Regarding the style of tagsmathtoolsis helping you definitely, but I think thecrefissue still persists, however.mathtoolsloadsamsmath(and extends it) so you will be able to use everything you already applied fromamsmath
– Christian Hupfer
Nov 9 '17 at 12:15
add a comment |
1
See themathtoolspackage for itsnewtagformmacro as well in order to simplify such styles of equation tags
– Christian Hupfer
Nov 9 '17 at 12:13
1
Do you mean thatmathtoolsprovides easier ways to do what I'm doing?
– Héctor
Nov 9 '17 at 12:14
1
Regarding the style of tagsmathtoolsis helping you definitely, but I think thecrefissue still persists, however.mathtoolsloadsamsmath(and extends it) so you will be able to use everything you already applied fromamsmath
– Christian Hupfer
Nov 9 '17 at 12:15
1
1
See the
mathtools package for its newtagform macro as well in order to simplify such styles of equation tags– Christian Hupfer
Nov 9 '17 at 12:13
See the
mathtools package for its newtagform macro as well in order to simplify such styles of equation tags– Christian Hupfer
Nov 9 '17 at 12:13
1
1
Do you mean that
mathtools provides easier ways to do what I'm doing?– Héctor
Nov 9 '17 at 12:14
Do you mean that
mathtools provides easier ways to do what I'm doing?– Héctor
Nov 9 '17 at 12:14
1
1
Regarding the style of tags
mathtools is helping you definitely, but I think the cref issue still persists, however. mathtools loads amsmath (and extends it) so you will be able to use everything you already applied from amsmath– Christian Hupfer
Nov 9 '17 at 12:15
Regarding the style of tags
mathtools is helping you definitely, but I think the cref issue still persists, however. mathtools loads amsmath (and extends it) so you will be able to use everything you already applied from amsmath– Christian Hupfer
Nov 9 '17 at 12:15
add a comment |
2 Answers
2
active
oldest
votes
In my point of view the easiest (though not most elegant, perhaps) way is to change creflabelformat for the equation counter as well, applying the tagform@ macro explicitly for this.
creflabelformat{equation}{#2tagform@{#1}#3}
The #2 and #3 are reserved for hyperref targets.
Here's the full code.
documentclass{article}
usepackage{amsmath}
usepackage[capitalise,noabbrev,]{cleveref}
makeatletter
deftagform@#1{maketag@@@{[ignorespaces#1unskip@@italiccorr]}}
creflabelformat{equation}{#2tagform@{#1}#3}
makeatother
begin{document}
cref{eq1} is fancy
begin{equation}label{eq1}
a = b
end{equation}
end{document}

add a comment |
The following solution uses the newtagform and usetagform macros of the mathtools package and the creflabelformat macro of the cleveref package to achieve your formatting objective.
documentclass{article}
usepackage{mathtools} % for "newtagform" macro
newtagform{brackets}{[}{]}
usetagform{brackets} % employ square brackets as delimiters around eq. numbers
usepackage[capitalise,noabbrev]{cleveref}
creflabelformat{equation}{#2{upshape[#1]}#3}
begin{document}
cref{eq1} is fancy.
begin{equation}label{eq1}
a = b
end{equation}
end{document}
1
I wonder whether the second occurrence of#2should instead be#3(viz., increflabelformat{equation}{#2{upshape[#1]}#2})? From thecleverefdocumentation, §8.1.2: The<format>argument “should contain the three arguments#1,#2and#3, the first being the formatted version of the label counter, the others determining the beginning and end of the portion that becomes a hyperlink when the hyperref package is loaded….#2and#3must appear in that order."
– Jim Ratliff
Feb 26 at 6:41
@JimRatliff - Many thanks for contacting me and for pointing out the error. I've fixed the code. Best, Mico
– Mico
Feb 26 at 8:45
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%2f400470%2fhow-to-make-cleveref-cross-references-match-a-modified-equation-label-style%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
In my point of view the easiest (though not most elegant, perhaps) way is to change creflabelformat for the equation counter as well, applying the tagform@ macro explicitly for this.
creflabelformat{equation}{#2tagform@{#1}#3}
The #2 and #3 are reserved for hyperref targets.
Here's the full code.
documentclass{article}
usepackage{amsmath}
usepackage[capitalise,noabbrev,]{cleveref}
makeatletter
deftagform@#1{maketag@@@{[ignorespaces#1unskip@@italiccorr]}}
creflabelformat{equation}{#2tagform@{#1}#3}
makeatother
begin{document}
cref{eq1} is fancy
begin{equation}label{eq1}
a = b
end{equation}
end{document}

add a comment |
In my point of view the easiest (though not most elegant, perhaps) way is to change creflabelformat for the equation counter as well, applying the tagform@ macro explicitly for this.
creflabelformat{equation}{#2tagform@{#1}#3}
The #2 and #3 are reserved for hyperref targets.
Here's the full code.
documentclass{article}
usepackage{amsmath}
usepackage[capitalise,noabbrev,]{cleveref}
makeatletter
deftagform@#1{maketag@@@{[ignorespaces#1unskip@@italiccorr]}}
creflabelformat{equation}{#2tagform@{#1}#3}
makeatother
begin{document}
cref{eq1} is fancy
begin{equation}label{eq1}
a = b
end{equation}
end{document}

add a comment |
In my point of view the easiest (though not most elegant, perhaps) way is to change creflabelformat for the equation counter as well, applying the tagform@ macro explicitly for this.
creflabelformat{equation}{#2tagform@{#1}#3}
The #2 and #3 are reserved for hyperref targets.
Here's the full code.
documentclass{article}
usepackage{amsmath}
usepackage[capitalise,noabbrev,]{cleveref}
makeatletter
deftagform@#1{maketag@@@{[ignorespaces#1unskip@@italiccorr]}}
creflabelformat{equation}{#2tagform@{#1}#3}
makeatother
begin{document}
cref{eq1} is fancy
begin{equation}label{eq1}
a = b
end{equation}
end{document}

In my point of view the easiest (though not most elegant, perhaps) way is to change creflabelformat for the equation counter as well, applying the tagform@ macro explicitly for this.
creflabelformat{equation}{#2tagform@{#1}#3}
The #2 and #3 are reserved for hyperref targets.
Here's the full code.
documentclass{article}
usepackage{amsmath}
usepackage[capitalise,noabbrev,]{cleveref}
makeatletter
deftagform@#1{maketag@@@{[ignorespaces#1unskip@@italiccorr]}}
creflabelformat{equation}{#2tagform@{#1}#3}
makeatother
begin{document}
cref{eq1} is fancy
begin{equation}label{eq1}
a = b
end{equation}
end{document}

answered Nov 9 '17 at 12:09
Christian HupferChristian Hupfer
151k15199396
151k15199396
add a comment |
add a comment |
The following solution uses the newtagform and usetagform macros of the mathtools package and the creflabelformat macro of the cleveref package to achieve your formatting objective.
documentclass{article}
usepackage{mathtools} % for "newtagform" macro
newtagform{brackets}{[}{]}
usetagform{brackets} % employ square brackets as delimiters around eq. numbers
usepackage[capitalise,noabbrev]{cleveref}
creflabelformat{equation}{#2{upshape[#1]}#3}
begin{document}
cref{eq1} is fancy.
begin{equation}label{eq1}
a = b
end{equation}
end{document}
1
I wonder whether the second occurrence of#2should instead be#3(viz., increflabelformat{equation}{#2{upshape[#1]}#2})? From thecleverefdocumentation, §8.1.2: The<format>argument “should contain the three arguments#1,#2and#3, the first being the formatted version of the label counter, the others determining the beginning and end of the portion that becomes a hyperlink when the hyperref package is loaded….#2and#3must appear in that order."
– Jim Ratliff
Feb 26 at 6:41
@JimRatliff - Many thanks for contacting me and for pointing out the error. I've fixed the code. Best, Mico
– Mico
Feb 26 at 8:45
add a comment |
The following solution uses the newtagform and usetagform macros of the mathtools package and the creflabelformat macro of the cleveref package to achieve your formatting objective.
documentclass{article}
usepackage{mathtools} % for "newtagform" macro
newtagform{brackets}{[}{]}
usetagform{brackets} % employ square brackets as delimiters around eq. numbers
usepackage[capitalise,noabbrev]{cleveref}
creflabelformat{equation}{#2{upshape[#1]}#3}
begin{document}
cref{eq1} is fancy.
begin{equation}label{eq1}
a = b
end{equation}
end{document}
1
I wonder whether the second occurrence of#2should instead be#3(viz., increflabelformat{equation}{#2{upshape[#1]}#2})? From thecleverefdocumentation, §8.1.2: The<format>argument “should contain the three arguments#1,#2and#3, the first being the formatted version of the label counter, the others determining the beginning and end of the portion that becomes a hyperlink when the hyperref package is loaded….#2and#3must appear in that order."
– Jim Ratliff
Feb 26 at 6:41
@JimRatliff - Many thanks for contacting me and for pointing out the error. I've fixed the code. Best, Mico
– Mico
Feb 26 at 8:45
add a comment |
The following solution uses the newtagform and usetagform macros of the mathtools package and the creflabelformat macro of the cleveref package to achieve your formatting objective.
documentclass{article}
usepackage{mathtools} % for "newtagform" macro
newtagform{brackets}{[}{]}
usetagform{brackets} % employ square brackets as delimiters around eq. numbers
usepackage[capitalise,noabbrev]{cleveref}
creflabelformat{equation}{#2{upshape[#1]}#3}
begin{document}
cref{eq1} is fancy.
begin{equation}label{eq1}
a = b
end{equation}
end{document}
The following solution uses the newtagform and usetagform macros of the mathtools package and the creflabelformat macro of the cleveref package to achieve your formatting objective.
documentclass{article}
usepackage{mathtools} % for "newtagform" macro
newtagform{brackets}{[}{]}
usetagform{brackets} % employ square brackets as delimiters around eq. numbers
usepackage[capitalise,noabbrev]{cleveref}
creflabelformat{equation}{#2{upshape[#1]}#3}
begin{document}
cref{eq1} is fancy.
begin{equation}label{eq1}
a = b
end{equation}
end{document}
edited Feb 26 at 8:44
answered Nov 9 '17 at 13:43
MicoMico
281k31385774
281k31385774
1
I wonder whether the second occurrence of#2should instead be#3(viz., increflabelformat{equation}{#2{upshape[#1]}#2})? From thecleverefdocumentation, §8.1.2: The<format>argument “should contain the three arguments#1,#2and#3, the first being the formatted version of the label counter, the others determining the beginning and end of the portion that becomes a hyperlink when the hyperref package is loaded….#2and#3must appear in that order."
– Jim Ratliff
Feb 26 at 6:41
@JimRatliff - Many thanks for contacting me and for pointing out the error. I've fixed the code. Best, Mico
– Mico
Feb 26 at 8:45
add a comment |
1
I wonder whether the second occurrence of#2should instead be#3(viz., increflabelformat{equation}{#2{upshape[#1]}#2})? From thecleverefdocumentation, §8.1.2: The<format>argument “should contain the three arguments#1,#2and#3, the first being the formatted version of the label counter, the others determining the beginning and end of the portion that becomes a hyperlink when the hyperref package is loaded….#2and#3must appear in that order."
– Jim Ratliff
Feb 26 at 6:41
@JimRatliff - Many thanks for contacting me and for pointing out the error. I've fixed the code. Best, Mico
– Mico
Feb 26 at 8:45
1
1
I wonder whether the second occurrence of
#2 should instead be #3 (viz., in creflabelformat{equation}{#2{upshape[#1]}#2})? From the cleveref documentation, §8.1.2: The <format> argument “should contain the three arguments #1, #2 and #3, the first being the formatted version of the label counter, the others determining the beginning and end of the portion that becomes a hyperlink when the hyperref package is loaded…. #2 and #3 must appear in that order."– Jim Ratliff
Feb 26 at 6:41
I wonder whether the second occurrence of
#2 should instead be #3 (viz., in creflabelformat{equation}{#2{upshape[#1]}#2})? From the cleveref documentation, §8.1.2: The <format> argument “should contain the three arguments #1, #2 and #3, the first being the formatted version of the label counter, the others determining the beginning and end of the portion that becomes a hyperlink when the hyperref package is loaded…. #2 and #3 must appear in that order."– Jim Ratliff
Feb 26 at 6:41
@JimRatliff - Many thanks for contacting me and for pointing out the error. I've fixed the code. Best, Mico
– Mico
Feb 26 at 8:45
@JimRatliff - Many thanks for contacting me and for pointing out the error. I've fixed the code. Best, Mico
– Mico
Feb 26 at 8:45
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%2f400470%2fhow-to-make-cleveref-cross-references-match-a-modified-equation-label-style%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
1
See the
mathtoolspackage for itsnewtagformmacro as well in order to simplify such styles of equation tags– Christian Hupfer
Nov 9 '17 at 12:13
1
Do you mean that
mathtoolsprovides easier ways to do what I'm doing?– Héctor
Nov 9 '17 at 12:14
1
Regarding the style of tags
mathtoolsis helping you definitely, but I think thecrefissue still persists, however.mathtoolsloadsamsmath(and extends it) so you will be able to use everything you already applied fromamsmath– Christian Hupfer
Nov 9 '17 at 12:15