Transpose a matrix and parenthesisWhat is the difference between empty and @empty?Redefine marginpar with...
Intern applicant asking for compensation equivalent to that of permanent employee
What incentives do banks have to gather up loans into pools (backed by Ginnie Mae)and selling them?
Consequences of lack of rigour
Why avoid shared user accounts?
Removing disk while game is suspended
Graph with overlapping labels
Can we harness gravitational potential energy?
Concatenation of fieldvalue and fieldname (handling of NULL)
Citing paywalled articles accessed via illegal web sharing
How can my powered armor quickly replace its ceramic plates?
Why was Lupin comfortable with saying Voldemort's name?
Nested word series [humans only]
Which one of these password policies are more secure?
How did Ancient Greek 'πυρ' become English 'fire?'
Can a Pact of the Blade warlock use the correct existing pact magic weapon so it functions as a "Returning" weapon?
Why is it that Bernie Sanders is always called a "socialist"?
Does a phylactery of a lich have to be a box?
How can I get my players to come to the game session after agreeing to a date?
Why would space fleets be aligned?
Why publish a research paper when a blog post or a lecture slide can have more citation count than a journal paper?
IGBT transistor with auxiliary emitter
Can a hotel cancel a confirmed reservation?
Positioning node within rectangle Tikz
Hybrid flat to drop conversion advice
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
2 hours 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 2 hours 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
2 hours 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
2 hours 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
2 hours 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
2 hours 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 2 hours 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 2 hours ago
answered 2 hours 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
2 hours ago