Check if argument is math expression. The case of making the first letter uppercase
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
In this example:
documentclassarticle
usepackagexspace
newcommandptensuremathp_Txspace
newcommandcapitalise[1]
% if string
MakeUppercase #1
% if math expression
#1
begindocument
capitaliseabc
capitalisept
enddocument
capitalise
should capitalise the first letter of the argument if it is a string and should leave the argument unchanged if it is a math expression.
How to check if the argument is a math expression?
math-mode macros capitalization
 |Â
show 4 more comments
up vote
1
down vote
favorite
In this example:
documentclassarticle
usepackagexspace
newcommandptensuremathp_Txspace
newcommandcapitalise[1]
% if string
MakeUppercase #1
% if math expression
#1
begindocument
capitaliseabc
capitalisept
enddocument
capitalise
should capitalise the first letter of the argument if it is a string and should leave the argument unchanged if it is a math expression.
How to check if the argument is a math expression?
math-mode macros capitalization
3
expl3
containstl_upper_case:n
, which ignores math when changing case.
â Phelype Oleinik
1 hour ago
1
See thetextcase
package, it has an alternative toMakeUppercase
that in most cases leaves math alone.
â daleif
1 hour ago
1
ifmmode
tells you if you are in math mode, but obviously this does not work if you switch to math mode inside the argument ofcapitalise
.
â marmot
1 hour ago
@daleif I checkedtextcase
but it nevertheless also capitalised the math expression.
â Viesturs
1 hour ago
1
@Viesturs remember to read the manual either use the overload option like David did or use itsMakeTextUppercase
â daleif
21 mins ago
 |Â
show 4 more comments
up vote
1
down vote
favorite
up vote
1
down vote
favorite
In this example:
documentclassarticle
usepackagexspace
newcommandptensuremathp_Txspace
newcommandcapitalise[1]
% if string
MakeUppercase #1
% if math expression
#1
begindocument
capitaliseabc
capitalisept
enddocument
capitalise
should capitalise the first letter of the argument if it is a string and should leave the argument unchanged if it is a math expression.
How to check if the argument is a math expression?
math-mode macros capitalization
In this example:
documentclassarticle
usepackagexspace
newcommandptensuremathp_Txspace
newcommandcapitalise[1]
% if string
MakeUppercase #1
% if math expression
#1
begindocument
capitaliseabc
capitalisept
enddocument
capitalise
should capitalise the first letter of the argument if it is a string and should leave the argument unchanged if it is a math expression.
How to check if the argument is a math expression?
math-mode macros capitalization
math-mode macros capitalization
edited 52 mins ago
asked 1 hour ago
Viesturs
1,3502921
1,3502921
3
expl3
containstl_upper_case:n
, which ignores math when changing case.
â Phelype Oleinik
1 hour ago
1
See thetextcase
package, it has an alternative toMakeUppercase
that in most cases leaves math alone.
â daleif
1 hour ago
1
ifmmode
tells you if you are in math mode, but obviously this does not work if you switch to math mode inside the argument ofcapitalise
.
â marmot
1 hour ago
@daleif I checkedtextcase
but it nevertheless also capitalised the math expression.
â Viesturs
1 hour ago
1
@Viesturs remember to read the manual either use the overload option like David did or use itsMakeTextUppercase
â daleif
21 mins ago
 |Â
show 4 more comments
3
expl3
containstl_upper_case:n
, which ignores math when changing case.
â Phelype Oleinik
1 hour ago
1
See thetextcase
package, it has an alternative toMakeUppercase
that in most cases leaves math alone.
â daleif
1 hour ago
1
ifmmode
tells you if you are in math mode, but obviously this does not work if you switch to math mode inside the argument ofcapitalise
.
â marmot
1 hour ago
@daleif I checkedtextcase
but it nevertheless also capitalised the math expression.
â Viesturs
1 hour ago
1
@Viesturs remember to read the manual either use the overload option like David did or use itsMakeTextUppercase
â daleif
21 mins ago
3
3
expl3
contains tl_upper_case:n
, which ignores math when changing case.â Phelype Oleinik
1 hour ago
expl3
contains tl_upper_case:n
, which ignores math when changing case.â Phelype Oleinik
1 hour ago
1
1
See the
textcase
package, it has an alternative to MakeUppercase
that in most cases leaves math alone.â daleif
1 hour ago
See the
textcase
package, it has an alternative to MakeUppercase
that in most cases leaves math alone.â daleif
1 hour ago
1
1
ifmmode
tells you if you are in math mode, but obviously this does not work if you switch to math mode inside the argument of capitalise
.â marmot
1 hour ago
ifmmode
tells you if you are in math mode, but obviously this does not work if you switch to math mode inside the argument of capitalise
.â marmot
1 hour ago
@daleif I checked
textcase
but it nevertheless also capitalised the math expression.â Viesturs
1 hour ago
@daleif I checked
textcase
but it nevertheless also capitalised the math expression.â Viesturs
1 hour ago
1
1
@Viesturs remember to read the manual either use the overload option like David did or use its
MakeTextUppercase
â daleif
21 mins ago
@Viesturs remember to read the manual either use the overload option like David did or use its
MakeTextUppercase
â daleif
21 mins ago
 |Â
show 4 more comments
2 Answers
2
active
oldest
votes
up vote
3
down vote
accepted
Using tl_mixed_case:n
this is trivial
documentclassarticle
usepackagexparse
ExplSyntaxOn
NewExpandableDocumentCommandcapitalisemtl_mixed_case:n#1
ExplSyntaxOff
newcommandptensuremathp_T
begindocument
capitaliseabc
capitalisept
enddocument
The way this works is by expanding arguments token-by-token and then examining the 'unexpandable' results to see if they can be case-changed. In the case of math mode material, any tokens which produce a $
start a 'no case changing' approach, which is stopped by a matching $
(or for (
/)
pairs). AS ensuremath
expands to insert a $
, this all works 'as expected'.
add a comment |Â
up vote
2
down vote
documentclassarticle
usepackagexspace
usepackage[overload]textcase
newcommandptensuremathp_Txspace
newcommandcapitalise[1]
% if string
MakeUppercase #1
% if math expression
#1
begindocument
capitaliseabc
capitalisept
enddocument
Thanks, now it works. How can I check from which package exactly a command such asMakeUppercase
is coming? I tried to useshow
but I think it didn't work out.
â Viesturs
16 mins ago
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
Using tl_mixed_case:n
this is trivial
documentclassarticle
usepackagexparse
ExplSyntaxOn
NewExpandableDocumentCommandcapitalisemtl_mixed_case:n#1
ExplSyntaxOff
newcommandptensuremathp_T
begindocument
capitaliseabc
capitalisept
enddocument
The way this works is by expanding arguments token-by-token and then examining the 'unexpandable' results to see if they can be case-changed. In the case of math mode material, any tokens which produce a $
start a 'no case changing' approach, which is stopped by a matching $
(or for (
/)
pairs). AS ensuremath
expands to insert a $
, this all works 'as expected'.
add a comment |Â
up vote
3
down vote
accepted
Using tl_mixed_case:n
this is trivial
documentclassarticle
usepackagexparse
ExplSyntaxOn
NewExpandableDocumentCommandcapitalisemtl_mixed_case:n#1
ExplSyntaxOff
newcommandptensuremathp_T
begindocument
capitaliseabc
capitalisept
enddocument
The way this works is by expanding arguments token-by-token and then examining the 'unexpandable' results to see if they can be case-changed. In the case of math mode material, any tokens which produce a $
start a 'no case changing' approach, which is stopped by a matching $
(or for (
/)
pairs). AS ensuremath
expands to insert a $
, this all works 'as expected'.
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
Using tl_mixed_case:n
this is trivial
documentclassarticle
usepackagexparse
ExplSyntaxOn
NewExpandableDocumentCommandcapitalisemtl_mixed_case:n#1
ExplSyntaxOff
newcommandptensuremathp_T
begindocument
capitaliseabc
capitalisept
enddocument
The way this works is by expanding arguments token-by-token and then examining the 'unexpandable' results to see if they can be case-changed. In the case of math mode material, any tokens which produce a $
start a 'no case changing' approach, which is stopped by a matching $
(or for (
/)
pairs). AS ensuremath
expands to insert a $
, this all works 'as expected'.
Using tl_mixed_case:n
this is trivial
documentclassarticle
usepackagexparse
ExplSyntaxOn
NewExpandableDocumentCommandcapitalisemtl_mixed_case:n#1
ExplSyntaxOff
newcommandptensuremathp_T
begindocument
capitaliseabc
capitalisept
enddocument
The way this works is by expanding arguments token-by-token and then examining the 'unexpandable' results to see if they can be case-changed. In the case of math mode material, any tokens which produce a $
start a 'no case changing' approach, which is stopped by a matching $
(or for (
/)
pairs). AS ensuremath
expands to insert a $
, this all works 'as expected'.
answered 57 mins ago
Joseph Wrightâ¦
198k21545865
198k21545865
add a comment |Â
add a comment |Â
up vote
2
down vote
documentclassarticle
usepackagexspace
usepackage[overload]textcase
newcommandptensuremathp_Txspace
newcommandcapitalise[1]
% if string
MakeUppercase #1
% if math expression
#1
begindocument
capitaliseabc
capitalisept
enddocument
Thanks, now it works. How can I check from which package exactly a command such asMakeUppercase
is coming? I tried to useshow
but I think it didn't work out.
â Viesturs
16 mins ago
add a comment |Â
up vote
2
down vote
documentclassarticle
usepackagexspace
usepackage[overload]textcase
newcommandptensuremathp_Txspace
newcommandcapitalise[1]
% if string
MakeUppercase #1
% if math expression
#1
begindocument
capitaliseabc
capitalisept
enddocument
Thanks, now it works. How can I check from which package exactly a command such asMakeUppercase
is coming? I tried to useshow
but I think it didn't work out.
â Viesturs
16 mins ago
add a comment |Â
up vote
2
down vote
up vote
2
down vote
documentclassarticle
usepackagexspace
usepackage[overload]textcase
newcommandptensuremathp_Txspace
newcommandcapitalise[1]
% if string
MakeUppercase #1
% if math expression
#1
begindocument
capitaliseabc
capitalisept
enddocument
documentclassarticle
usepackagexspace
usepackage[overload]textcase
newcommandptensuremathp_Txspace
newcommandcapitalise[1]
% if string
MakeUppercase #1
% if math expression
#1
begindocument
capitaliseabc
capitalisept
enddocument
answered 24 mins ago
David Carlisle
471k3811001829
471k3811001829
Thanks, now it works. How can I check from which package exactly a command such asMakeUppercase
is coming? I tried to useshow
but I think it didn't work out.
â Viesturs
16 mins ago
add a comment |Â
Thanks, now it works. How can I check from which package exactly a command such asMakeUppercase
is coming? I tried to useshow
but I think it didn't work out.
â Viesturs
16 mins ago
Thanks, now it works. How can I check from which package exactly a command such as
MakeUppercase
is coming? I tried to use show
but I think it didn't work out.â Viesturs
16 mins ago
Thanks, now it works. How can I check from which package exactly a command such as
MakeUppercase
is coming? I tried to use show
but I think it didn't work out.â Viesturs
16 mins ago
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f454933%2fcheck-if-argument-is-math-expression-the-case-of-making-the-first-letter-upperc%23new-answer', 'question_page');
);
Post as a guest
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
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
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
3
expl3
containstl_upper_case:n
, which ignores math when changing case.â Phelype Oleinik
1 hour ago
1
See the
textcase
package, it has an alternative toMakeUppercase
that in most cases leaves math alone.â daleif
1 hour ago
1
ifmmode
tells you if you are in math mode, but obviously this does not work if you switch to math mode inside the argument ofcapitalise
.â marmot
1 hour ago
@daleif I checked
textcase
but it nevertheless also capitalised the math expression.â Viesturs
1 hour ago
1
@Viesturs remember to read the manual either use the overload option like David did or use its
MakeTextUppercase
â daleif
21 mins ago