Transpose a matrix and parenthesisWhat is the difference between empty and @empty?Redefine marginpar with...
If I delete my router's history can my ISP still provide it to my parents?
Which one of these password policies are more secure?
Bash Script Function Return True-False
How did Ancient Greek 'πυρ' become English 'fire?'
Why did the villain in the first Men in Black movie care about Earth's Cockroaches?
What is 6÷2×(1+2) =?
Why was Lupin comfortable with saying Voldemort's name?
Can you tell from a blurry photo if focus was too close or too far?
Why do neural networks need so many training examples to perform?
Can I write a book of my D&D game?
Partial vs Complete Catchup: what are the differences in terms of security?
Why publish a research paper when a blog post or a lecture slide can have more citation count than a journal paper?
Early credit roll before the end of the film
Transpose a matrix and parenthesis
Why did Luke use his left hand to shoot?
What incentives do banks have to gather up loans into pools (backed by Ginnie Mae)and selling them?
How much mayhem could I cause as a sentient fish?
LuaTex and em dashes
Describing what the world looks like in UV and IR
Citing paywalled articles accessed via illegal web sharing
Non-Cancer terminal illness that can affect young (age 10-13) girls?
Porting Linux to another platform requirements
What are "industrial chops"?
Why is working on the same position for more than 15 years not a red flag?
Transpose a matrix and parenthesis
What is the difference between empty and @empty?Redefine marginpar with renewcommandRead command with varying input argumentsAsymetric behaviour in user command with conditionalsName separators, if condition for same commandnewcommand with optional multi-line argument and implicit itemize environmentDefining a command that scans every arguments' macro “looking for” a tokenUsing fully expanded result as a simple string (with citet and IfSubStr)Define a new command with parameters inside newcommandHow to avoid using curly braces when placing a DeclareMathOperator command in subscript or superscript, while preserving spacing?
I would like to define a command transp
having eventually one argument : the name of the matrix and finally two outputs.
transp{A}
is the matrix A^T between parenthesis,
transp A
is just the matrix A^T.
I tried this command :
newcommand{transp}[1]{
ifstrempty{#1}{{}^{text{tbf{T}}} }{{}^{text{tbf{T}}} left( #1 right)}}
but to print the transpose symbol I have to write transp{}
. Can I modify the previous command in order to just write transp
(as mentioned in 2.) ?
macros conditionals math-operators
add a comment |
I would like to define a command transp
having eventually one argument : the name of the matrix and finally two outputs.
transp{A}
is the matrix A^T between parenthesis,
transp A
is just the matrix A^T.
I tried this command :
newcommand{transp}[1]{
ifstrempty{#1}{{}^{text{tbf{T}}} }{{}^{text{tbf{T}}} left( #1 right)}}
but to print the transpose symbol I have to write transp{}
. Can I modify the previous command in order to just write transp
(as mentioned in 2.) ?
macros conditionals math-operators
1
Usuallyfoo A
andfoo{A}
are the same for a macrofoo
taking an argument. So this is not easily done and would go against the normal behaviour (I don't want to say good practice, because I'm led to believe that it would be better practice to use braces even for one-token arguments). I think I saw a related question a while ago, but I can't find it now and it might have been about something else entirely.
– moewe
1 hour ago
add a comment |
I would like to define a command transp
having eventually one argument : the name of the matrix and finally two outputs.
transp{A}
is the matrix A^T between parenthesis,
transp A
is just the matrix A^T.
I tried this command :
newcommand{transp}[1]{
ifstrempty{#1}{{}^{text{tbf{T}}} }{{}^{text{tbf{T}}} left( #1 right)}}
but to print the transpose symbol I have to write transp{}
. Can I modify the previous command in order to just write transp
(as mentioned in 2.) ?
macros conditionals math-operators
I would like to define a command transp
having eventually one argument : the name of the matrix and finally two outputs.
transp{A}
is the matrix A^T between parenthesis,
transp A
is just the matrix A^T.
I tried this command :
newcommand{transp}[1]{
ifstrempty{#1}{{}^{text{tbf{T}}} }{{}^{text{tbf{T}}} left( #1 right)}}
but to print the transpose symbol I have to write transp{}
. Can I modify the previous command in order to just write transp
(as mentioned in 2.) ?
macros conditionals math-operators
macros conditionals math-operators
asked 1 hour ago
jowe_19jowe_19
6510
6510
1
Usuallyfoo A
andfoo{A}
are the same for a macrofoo
taking an argument. So this is not easily done and would go against the normal behaviour (I don't want to say good practice, because I'm led to believe that it would be better practice to use braces even for one-token arguments). I think I saw a related question a while ago, but I can't find it now and it might have been about something else entirely.
– moewe
1 hour ago
add a comment |
1
Usuallyfoo A
andfoo{A}
are the same for a macrofoo
taking an argument. So this is not easily done and would go against the normal behaviour (I don't want to say good practice, because I'm led to believe that it would be better practice to use braces even for one-token arguments). I think I saw a related question a while ago, but I can't find it now and it might have been about something else entirely.
– moewe
1 hour ago
1
1
Usually
foo A
and foo{A}
are the same for a macro foo
taking an argument. So this is not easily done and would go against the normal behaviour (I don't want to say good practice, because I'm led to believe that it would be better practice to use braces even for one-token arguments). I think I saw a related question a while ago, but I can't find it now and it might have been about something else entirely.– moewe
1 hour ago
Usually
foo A
and foo{A}
are the same for a macro foo
taking an argument. So this is not easily done and would go against the normal behaviour (I don't want to say good practice, because I'm led to believe that it would be better practice to use braces even for one-token arguments). I think I saw a related question a while ago, but I can't find it now and it might have been about something else entirely.– moewe
1 hour ago
add a comment |
2 Answers
2
active
oldest
votes
According to the standard TeX syntax, transp{A}
and transp A
are completely equivalent.
You might do in the following way:
documentclass{article}
usepackage{amsmath}
makeatletter
DeclareRobustCommand{transp}{%
@ifnextcharbgrouptransp@parentransp@simple
}
newcommand{transp@paren}[1]{(#1)^{T}}
newcommand{transp@simple}[1]{#1^{T}}
makeatother
begin{document}
$transp A+transp{B+C}$
end{document}
but I would avoid it, because it's confusing.
I find the following much better. You explicitly mark where you want parentheses by adding *
.
documentclass{article}
usepackage{amsmath}
usepackage{xparse}
NewDocumentCommand{transp}{sm}{%
IfBooleanTF{#1}{(#2)^{T}}{#2^{T}}%
}
begin{document}
$transp{A}+transp*{B+C}$
end{document}
add a comment |
The following seems to work, but I doubt it is a good idea in general. Usually foo A
and foo {A}
give the same result for macros with one argument and the braces are needed in case the argument consists of more than one token. Indeed I would say that it is good practice to use braces for mandatory arguments even if they enclose only one token.
Note that transp
without braces can only accept one token as its argument, so transp A+B
is transp A
and +B
. In particular then, transp mathbf{A}
dies horribly.
documentclass{article}
usepackage{amsmath}
makeatletter
newcommand*{transp@nb}[1]{#1^{T}}
newcommand*{transp@br}[1]{(#1)^{T}}
newcommand{transp}{}
protecteddeftransp{%
@ifnextcharbgroup
{transp@br}
{transp@nb}}
makeatother
begin{document}
begin{align*}
transp A \
transp{A}
end{align*}
end{document}
A starred variant would be more common (see also egreg's answer)
documentclass{article}
usepackage{amsmath}
makeatletter
newcommand*{transp@nb}[1]{#1^{T}}
newcommand*{transp@br}[1]{(#1)^{T}}
newcommand{transp}{}
protecteddeftransp{%
@ifstar
{transp@br}
{transp@nb}}
makeatother
begin{document}
begin{align*}
transp{A} \
transp*{A}
end{align*}
end{document}
but you could also use an optional argument (p
for parentheses, b
for brackets)
documentclass{article}
usepackage{amsmath}
makeatletter
newcommand{transp}[2][]{%
if#1p
(#2)
else
if#1b
[A]
else
A
fi
fi^{T}
}
makeatother
begin{document}
begin{align*}
transp{A} \
transp[b]{A}
end{align*}
end{document}
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%2f477114%2ftranspose-a-matrix-and-parenthesis%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
According to the standard TeX syntax, transp{A}
and transp A
are completely equivalent.
You might do in the following way:
documentclass{article}
usepackage{amsmath}
makeatletter
DeclareRobustCommand{transp}{%
@ifnextcharbgrouptransp@parentransp@simple
}
newcommand{transp@paren}[1]{(#1)^{T}}
newcommand{transp@simple}[1]{#1^{T}}
makeatother
begin{document}
$transp A+transp{B+C}$
end{document}
but I would avoid it, because it's confusing.
I find the following much better. You explicitly mark where you want parentheses by adding *
.
documentclass{article}
usepackage{amsmath}
usepackage{xparse}
NewDocumentCommand{transp}{sm}{%
IfBooleanTF{#1}{(#2)^{T}}{#2^{T}}%
}
begin{document}
$transp{A}+transp*{B+C}$
end{document}
add a comment |
According to the standard TeX syntax, transp{A}
and transp A
are completely equivalent.
You might do in the following way:
documentclass{article}
usepackage{amsmath}
makeatletter
DeclareRobustCommand{transp}{%
@ifnextcharbgrouptransp@parentransp@simple
}
newcommand{transp@paren}[1]{(#1)^{T}}
newcommand{transp@simple}[1]{#1^{T}}
makeatother
begin{document}
$transp A+transp{B+C}$
end{document}
but I would avoid it, because it's confusing.
I find the following much better. You explicitly mark where you want parentheses by adding *
.
documentclass{article}
usepackage{amsmath}
usepackage{xparse}
NewDocumentCommand{transp}{sm}{%
IfBooleanTF{#1}{(#2)^{T}}{#2^{T}}%
}
begin{document}
$transp{A}+transp*{B+C}$
end{document}
add a comment |
According to the standard TeX syntax, transp{A}
and transp A
are completely equivalent.
You might do in the following way:
documentclass{article}
usepackage{amsmath}
makeatletter
DeclareRobustCommand{transp}{%
@ifnextcharbgrouptransp@parentransp@simple
}
newcommand{transp@paren}[1]{(#1)^{T}}
newcommand{transp@simple}[1]{#1^{T}}
makeatother
begin{document}
$transp A+transp{B+C}$
end{document}
but I would avoid it, because it's confusing.
I find the following much better. You explicitly mark where you want parentheses by adding *
.
documentclass{article}
usepackage{amsmath}
usepackage{xparse}
NewDocumentCommand{transp}{sm}{%
IfBooleanTF{#1}{(#2)^{T}}{#2^{T}}%
}
begin{document}
$transp{A}+transp*{B+C}$
end{document}
According to the standard TeX syntax, transp{A}
and transp A
are completely equivalent.
You might do in the following way:
documentclass{article}
usepackage{amsmath}
makeatletter
DeclareRobustCommand{transp}{%
@ifnextcharbgrouptransp@parentransp@simple
}
newcommand{transp@paren}[1]{(#1)^{T}}
newcommand{transp@simple}[1]{#1^{T}}
makeatother
begin{document}
$transp A+transp{B+C}$
end{document}
but I would avoid it, because it's confusing.
I find the following much better. You explicitly mark where you want parentheses by adding *
.
documentclass{article}
usepackage{amsmath}
usepackage{xparse}
NewDocumentCommand{transp}{sm}{%
IfBooleanTF{#1}{(#2)^{T}}{#2^{T}}%
}
begin{document}
$transp{A}+transp*{B+C}$
end{document}
answered 1 hour ago
egregegreg
723k8719163219
723k8719163219
add a comment |
add a comment |
The following seems to work, but I doubt it is a good idea in general. Usually foo A
and foo {A}
give the same result for macros with one argument and the braces are needed in case the argument consists of more than one token. Indeed I would say that it is good practice to use braces for mandatory arguments even if they enclose only one token.
Note that transp
without braces can only accept one token as its argument, so transp A+B
is transp A
and +B
. In particular then, transp mathbf{A}
dies horribly.
documentclass{article}
usepackage{amsmath}
makeatletter
newcommand*{transp@nb}[1]{#1^{T}}
newcommand*{transp@br}[1]{(#1)^{T}}
newcommand{transp}{}
protecteddeftransp{%
@ifnextcharbgroup
{transp@br}
{transp@nb}}
makeatother
begin{document}
begin{align*}
transp A \
transp{A}
end{align*}
end{document}
A starred variant would be more common (see also egreg's answer)
documentclass{article}
usepackage{amsmath}
makeatletter
newcommand*{transp@nb}[1]{#1^{T}}
newcommand*{transp@br}[1]{(#1)^{T}}
newcommand{transp}{}
protecteddeftransp{%
@ifstar
{transp@br}
{transp@nb}}
makeatother
begin{document}
begin{align*}
transp{A} \
transp*{A}
end{align*}
end{document}
but you could also use an optional argument (p
for parentheses, b
for brackets)
documentclass{article}
usepackage{amsmath}
makeatletter
newcommand{transp}[2][]{%
if#1p
(#2)
else
if#1b
[A]
else
A
fi
fi^{T}
}
makeatother
begin{document}
begin{align*}
transp{A} \
transp[b]{A}
end{align*}
end{document}
add a comment |
The following seems to work, but I doubt it is a good idea in general. Usually foo A
and foo {A}
give the same result for macros with one argument and the braces are needed in case the argument consists of more than one token. Indeed I would say that it is good practice to use braces for mandatory arguments even if they enclose only one token.
Note that transp
without braces can only accept one token as its argument, so transp A+B
is transp A
and +B
. In particular then, transp mathbf{A}
dies horribly.
documentclass{article}
usepackage{amsmath}
makeatletter
newcommand*{transp@nb}[1]{#1^{T}}
newcommand*{transp@br}[1]{(#1)^{T}}
newcommand{transp}{}
protecteddeftransp{%
@ifnextcharbgroup
{transp@br}
{transp@nb}}
makeatother
begin{document}
begin{align*}
transp A \
transp{A}
end{align*}
end{document}
A starred variant would be more common (see also egreg's answer)
documentclass{article}
usepackage{amsmath}
makeatletter
newcommand*{transp@nb}[1]{#1^{T}}
newcommand*{transp@br}[1]{(#1)^{T}}
newcommand{transp}{}
protecteddeftransp{%
@ifstar
{transp@br}
{transp@nb}}
makeatother
begin{document}
begin{align*}
transp{A} \
transp*{A}
end{align*}
end{document}
but you could also use an optional argument (p
for parentheses, b
for brackets)
documentclass{article}
usepackage{amsmath}
makeatletter
newcommand{transp}[2][]{%
if#1p
(#2)
else
if#1b
[A]
else
A
fi
fi^{T}
}
makeatother
begin{document}
begin{align*}
transp{A} \
transp[b]{A}
end{align*}
end{document}
add a comment |
The following seems to work, but I doubt it is a good idea in general. Usually foo A
and foo {A}
give the same result for macros with one argument and the braces are needed in case the argument consists of more than one token. Indeed I would say that it is good practice to use braces for mandatory arguments even if they enclose only one token.
Note that transp
without braces can only accept one token as its argument, so transp A+B
is transp A
and +B
. In particular then, transp mathbf{A}
dies horribly.
documentclass{article}
usepackage{amsmath}
makeatletter
newcommand*{transp@nb}[1]{#1^{T}}
newcommand*{transp@br}[1]{(#1)^{T}}
newcommand{transp}{}
protecteddeftransp{%
@ifnextcharbgroup
{transp@br}
{transp@nb}}
makeatother
begin{document}
begin{align*}
transp A \
transp{A}
end{align*}
end{document}
A starred variant would be more common (see also egreg's answer)
documentclass{article}
usepackage{amsmath}
makeatletter
newcommand*{transp@nb}[1]{#1^{T}}
newcommand*{transp@br}[1]{(#1)^{T}}
newcommand{transp}{}
protecteddeftransp{%
@ifstar
{transp@br}
{transp@nb}}
makeatother
begin{document}
begin{align*}
transp{A} \
transp*{A}
end{align*}
end{document}
but you could also use an optional argument (p
for parentheses, b
for brackets)
documentclass{article}
usepackage{amsmath}
makeatletter
newcommand{transp}[2][]{%
if#1p
(#2)
else
if#1b
[A]
else
A
fi
fi^{T}
}
makeatother
begin{document}
begin{align*}
transp{A} \
transp[b]{A}
end{align*}
end{document}
The following seems to work, but I doubt it is a good idea in general. Usually foo A
and foo {A}
give the same result for macros with one argument and the braces are needed in case the argument consists of more than one token. Indeed I would say that it is good practice to use braces for mandatory arguments even if they enclose only one token.
Note that transp
without braces can only accept one token as its argument, so transp A+B
is transp A
and +B
. In particular then, transp mathbf{A}
dies horribly.
documentclass{article}
usepackage{amsmath}
makeatletter
newcommand*{transp@nb}[1]{#1^{T}}
newcommand*{transp@br}[1]{(#1)^{T}}
newcommand{transp}{}
protecteddeftransp{%
@ifnextcharbgroup
{transp@br}
{transp@nb}}
makeatother
begin{document}
begin{align*}
transp A \
transp{A}
end{align*}
end{document}
A starred variant would be more common (see also egreg's answer)
documentclass{article}
usepackage{amsmath}
makeatletter
newcommand*{transp@nb}[1]{#1^{T}}
newcommand*{transp@br}[1]{(#1)^{T}}
newcommand{transp}{}
protecteddeftransp{%
@ifstar
{transp@br}
{transp@nb}}
makeatother
begin{document}
begin{align*}
transp{A} \
transp*{A}
end{align*}
end{document}
but you could also use an optional argument (p
for parentheses, b
for brackets)
documentclass{article}
usepackage{amsmath}
makeatletter
newcommand{transp}[2][]{%
if#1p
(#2)
else
if#1b
[A]
else
A
fi
fi^{T}
}
makeatother
begin{document}
begin{align*}
transp{A} \
transp[b]{A}
end{align*}
end{document}
edited 1 hour ago
answered 1 hour ago
moewemoewe
92.2k10115348
92.2k10115348
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%2f477114%2ftranspose-a-matrix-and-parenthesis%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
Usually
foo A
andfoo{A}
are the same for a macrofoo
taking an argument. So this is not easily done and would go against the normal behaviour (I don't want to say good practice, because I'm led to believe that it would be better practice to use braces even for one-token arguments). I think I saw a related question a while ago, but I can't find it now and it might have been about something else entirely.– moewe
1 hour ago