typesetting column vectorIs there a shorthand for matrices that doesn't use an environmentTypesetting a Row...
Why can't we play rap on piano?
Why can't I see bouncing of a switch on an oscilloscope?
LaTeX: Why are digits allowed in environments, but forbidden in commands?
Is it unprofessional to ask if a job posting on GlassDoor is real?
Watching something be written to a file live with tail
Convert two switches to a dual stack, and add outlet - possible here?
A case of the sniffles
Do I have a twin with permutated remainders?
Why is 150k or 200k jobs considered good when there's 300k+ births a month?
How to format long polynomial?
How much RAM could one put in a typical 80386 setup?
Can a Cauchy sequence converge for one metric while not converging for another?
What's the point of deactivating Num Lock on login screens?
When a company launches a new product do they "come out" with a new product or do they "come up" with a new product?
How old can references or sources in a thesis be?
Did Shadowfax go to Valinor?
Can I ask the recruiters in my resume to put the reason why I am rejected?
dbcc cleantable batch size explanation
Why are electrically insulating heatsinks so rare? Is it just cost?
Could an aircraft fly or hover using only jets of compressed air?
Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?
"You are your self first supporter", a more proper way to say it
If human space travel is limited by the G force vulnerability, is there a way to counter G forces?
Is it inappropriate for a student to attend their mentor's dissertation defense?
typesetting column vector
Is there a shorthand for matrices that doesn't use an environmentTypesetting a Row Vectorcolumn and row vectors with builtin math modeHow can I type an expression of a column vectorTypesetting a Row Vector - Vol 2Multicolumn vectorUse column-separator & (ampersand) inside newenvironmentAlignment accross multiple arrays/vectorsTypesetting a Row VectorHow do I add a vector to a table?Typesetting a pattern matching equationsmart vector commandSimple way to place an array of symbols above a letter?vertical dotted line in column vector / amsmath matrixDefining 'newcommand' without bracketsGenerate math symbols from argument
I would like to define a command which typesets a column vector.
For one vector I can have something like:
left(
begin{array}{c}
a\
b\
end{array}
right)
I would like the command to produce such a vector, for either 2 or 3 arguments. colvec{a}{b}{c}
should produce the same vector as above only with one more entry where colvec{a}{b}
will produce the above vector. How should I do it? I tried to overload a command name but that's impossible.
math-mode macros matrices vector
add a comment |
I would like to define a command which typesets a column vector.
For one vector I can have something like:
left(
begin{array}{c}
a\
b\
end{array}
right)
I would like the command to produce such a vector, for either 2 or 3 arguments. colvec{a}{b}{c}
should produce the same vector as above only with one more entry where colvec{a}{b}
will produce the above vector. How should I do it? I tried to overload a command name but that's impossible.
math-mode macros matrices vector
I've added a general solution (with a different syntax) at Typesetting a row vector
– egreg
Sep 30 '12 at 16:37
add a comment |
I would like to define a command which typesets a column vector.
For one vector I can have something like:
left(
begin{array}{c}
a\
b\
end{array}
right)
I would like the command to produce such a vector, for either 2 or 3 arguments. colvec{a}{b}{c}
should produce the same vector as above only with one more entry where colvec{a}{b}
will produce the above vector. How should I do it? I tried to overload a command name but that's impossible.
math-mode macros matrices vector
I would like to define a command which typesets a column vector.
For one vector I can have something like:
left(
begin{array}{c}
a\
b\
end{array}
right)
I would like the command to produce such a vector, for either 2 or 3 arguments. colvec{a}{b}{c}
should produce the same vector as above only with one more entry where colvec{a}{b}
will produce the above vector. How should I do it? I tried to overload a command name but that's impossible.
math-mode macros matrices vector
math-mode macros matrices vector
edited Jul 14 '17 at 14:06
samcarter
93.8k7107305
93.8k7107305
asked Sep 3 '10 at 13:40
DrorDror
11.2k1973150
11.2k1973150
I've added a general solution (with a different syntax) at Typesetting a row vector
– egreg
Sep 30 '12 at 16:37
add a comment |
I've added a general solution (with a different syntax) at Typesetting a row vector
– egreg
Sep 30 '12 at 16:37
I've added a general solution (with a different syntax) at Typesetting a row vector
– egreg
Sep 30 '12 at 16:37
I've added a general solution (with a different syntax) at Typesetting a row vector
– egreg
Sep 30 '12 at 16:37
add a comment |
9 Answers
9
active
oldest
votes
Note that you have extra space around your vector. You should probably using something like (pmatrix
is part of the amsmath
package)
begin{pmatrix}a\bend{pmatrix}
The standard LaTeX newcommand
provides a way to have a single optional argument.
newcommand*colvec[3][]{
begin{pmatrix}ifxrelax#1relaxelse#1\fi#2\#3end{pmatrix}
}
Note that you have to use colvec[a]{b}{c}
if you want three elements or colvec{a}{b}
if you want two.
Update
As per your request in the comments, here's one that takes any number of elements based on the number passed in the first argument.
newcountcolveccount
newcommand*colvec[1]{
globalcolveccount#1
begin{pmatrix}
colvecnext
}
defcolvecnext#1{
#1
globaladvancecolveccount-1
ifnumcolveccount>0
\
expandaftercolvecnext
else
end{pmatrix}
fi
}
You use it exactly as you wanted, colvec{5}{a}{b}{c}{d}{e}
.
Can it be extended to a vector of arbitrary length? say something like: colvec{5}{a}{b}{c}{d}{e} will produce a column vector with 5 entries?
– Dror
Sep 4 '10 at 9:18
16
Yeah, you could do that. Seems like more hassle than it's worth though. How aboutnewcommand*colvec[1]{begin{pmatrix}#1end{pmatrix}
and you writecolvec{a\b\c\d\e}
?
– TH.
Sep 4 '10 at 9:31
Yes!!! This is what I was looking for! Simple and easy to use. Thanks!
– Dror
Sep 4 '10 at 10:03
thesmallpmatrix
frommathtools
may also be handy
– daleif
Apr 21 '12 at 16:36
2
It'spsmallmatrix
notsmallpmatrix
. Just to clear up any mistakes (run into that problem just now).
– Florian Pilz
Mar 9 '13 at 10:14
add a comment |
This is a more "TeX" approach. The number of rows is arbitrary. The columns are aligned right by default, but can be c or l as well:
documentclass{article}
makeatletter
newcommand{Spvek}[2][r]{%
gdef@VORNE{1}
left(hskip-arraycolsep%
begin{array}{#1}vekSp@lten{#2}end{array}%
hskip-arraycolsepright)}
defvekSp@lten#1{xvekSp@lten#1;vekL@stLine;}
defvekL@stLine{vekL@stLine}
defxvekSp@lten#1;{deftemp{#1}%
ifxtempvekL@stLine
else
ifnum@VORNE=1gdef@VORNE{0}
else@arraycrfi%
#1%
expandafterxvekSp@lten
fi}
makeatother
begin{document}
[
Spvek{1;-2} quad Spvek[l]{1;-2;3}quad Spvek[c]{1;-2;-3}quadSpvek{1;2;-3;4}
]
end{document}
Output will be:
@percusse How did you crop the picture? I tried, but couldn't find a way. Thank you for cropping.
– Peter Breitfeld
Apr 21 '12 at 20:39
I did it manually using Paint :)
– percusse
Apr 21 '12 at 20:44
@PeterBreitfeld: See How do you crop an attached PDF?
– Werner
Apr 21 '12 at 22:26
+1 Just what I was looking for. But what does Spvek mean?
– Oriol
Mar 16 '13 at 20:17
Turns out to be abb. for spaltenvektor, in german pbreitfeld.de/schule2e.sty
– osolmaz
Nov 6 '13 at 20:13
add a comment |
For vectors with only two elements, or any doublet you want to express in column form, there is a standard LaTeX command in math mode $binom{a}{b}$ or alternatively ${n choose k}$. These look nice with tight vertically lengthened parentheses.
add a comment |
Since you specified only wanting two or three arguments (not an arbitrary number of them, as others here have given solutions for), you can use the xparse package to define commands with optional braced arguments. Something like (untested)
DeclareDocumentCommand colvec {mmg} {%
IfNoValueTF #3 {%
twocolvec {#1}{#2}
}{%
threecolvec {#1}{#2}{#3}
}%
}
Where the two intermediate functions (defined as appropriate) typeset the array as appropriate.
Does this means that I have to define separately the function twocolvec and threecolvec?
– Dror
Sep 4 '10 at 9:17
add a comment |
I would to supplement the solution above about Spvek by Peter B.
Yes, it is a more "TeX" approach but pure "TeX" approach is in two lines only:
defspvec#1{left(vcenter{halign{hfil$##$hfilcr spvecA#1;;}}right)}
defspvecA#1;{if;#1;else #1cr expandafter spvecA fi}
$spvec{1;2;3} + spvec{1;2;-3;4} + spvec{1;2}$
This solution will be work in LaTeX too because only TeX primitives are used here.
Does anyone care to elaborate on this code? I like it and want to modify it, but anything I attempt will fail. What is going on here$##$
?
– fborchers
yesterday
add a comment |
Here is my KISS-like solution (which is just a wrapper for pmatrix
from the amsmath
package, inspired by Garrys answer):
newcommand{myvec}[1]{ensuremath{begin{pmatrix}#1end{pmatrix}}}
Usage:
myvec{x\y\z}
The good thing is, you don't need to specify a number of elements or anything. You can just add more elements with \
. It also looks tidier in the tex-file then using the pmatrix
environment itself.
You can also use it for row-vectors:
myvec{a&b&c}
(For completion: Matrices work aswell, obviously: myvec{a&b \ c&d}
)
add a comment |
Years later and not very tex-y, but for some reason I really wanted to use commas as separators and ended up putting together the following:
usepackage{iftex}
RequireLuaTeX
usepackage{amsmath}
usepackage{luacode}
begin{luacode*}
mycolvec = { }
function mycolvec.replace(input)
tex.sprint(
"\ensuremath{\begin{pmatrix}"
.. string.gsub(input, ",", " \\ ")
.. "\end{pmatrix}}")
end
end{luacode*}
defcolvec#1{directlua{mycolvec.replace("#1")}}
Which, when added to the header, allows you to write out column vectors like this:
colvec{1, 2, 3}
colvec{8,6,7,5,3,0,9}
This requires that you compile your tex with lualatex instead of xetex or pdftex, but that shouldn't affect the rest of your document.
The seperator can be changed to any arbitrary character by changing the ","
on the .. string.gsub(...
line.
EDIT:
This method breaks when entering tokens (i.e. colvec{1 cdot 2, 2 cdot 3}
), for the reasons described here. As such I'll recommend egreg's answer on a related question, which provides the functionality I claim here without the same problem.
Welcome to TeX.Se.
– CampanIgnis
Sep 6 '18 at 1:29
add a comment |
This post presents another possible approach. It improves on this earlier post above. The idea is to use a similar plain TeX mechanism, but wrap it up in amsmath
s high level pmatrix
environment. This helps with fractions for example. The interface with parentheses is the same as used by PSTricks. Here is a working example:
documentclass[margin=2pt]{standalone}
usepackage{amsmath}
makeatletter
defvector(#1){%
mathchoice%
{pmatrix@i{vector@i#1,,}}%
{pmatrix@ii{vector@i#1,,}}%
{}% scriptstyle too small,
{}% ss style too small.
}
defvector@i#1,{if,#1,else{#1}crexpandaftervector@ifi}
defpmatrix@i#1{begin{pmatrix}#1end{pmatrix}}
defpmatrix@ii#1{left(!begin{smallmatrix}#1end{smallmatrix}!right)}
makeatother
begin{document}
$displaystylevector(-3,+4,5)$ and $vector(-3,+4,5)$
end{document}
When typesetting vectors with lots of fractions it is advisable to increase vertical spacing with:
renewcommand{arraystretch}{1.1}% stretch value 1.1 for example
Because the macros make use of the @i
notation the code will have to be placed inside at makeatletter
- makeatother
wrapping before document begins.
See here for a similar solution for row vectors.
@PhelypeOleinik: done.
– fborchers
8 hours ago
add a comment |
I can offer a macro colvec
within whose argument you can supply an arbitrary amount of undelimited arguments whereof each one will be taken for a component of the one-column-vector:
documentclass{article}
usepackage{amsmath}
makeatletter
%%=============================================================================
%% Paraphernalia:
%% UD@firstoftwo, UD@secondoftwo, UD@Exchange, UD@PassFirstToSecond,
%% UD@CheckWhetherNull, UD@CheckWhetherBlank, UD@ExtractFirstArg
%%=============================================================================
newcommandUD@firstoftwo[2]{#1}%
newcommandUD@secondoftwo[2]{#2}%
newcommandUD@Exchange[2]{#2#1}%
newcommandUD@PassFirstToSecond[2]{#2{#1}}%
%%-----------------------------------------------------------------------------
%% Check whether argument is empty:
%%.............................................................................
%% UD@CheckWhetherNull{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is empty>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is not empty>}%
%%
%% The gist of this macro comes from Robert R. Schneck's ifempty-macro:
%% <https://groups.google.com/forum/#!original/comp.text.tex/kuOEIQIrElc/lUg37FmhA74J>
newcommandUD@CheckWhetherNull[1]{%
romannumeral0expandafterUD@secondoftwostring{expandafter
UD@secondoftwoexpandafter{expandafter{string#1}expandafter
UD@secondoftwostring}expandafterUD@firstoftwoexpandafter{expandafter
UD@secondoftwostring}expandafterexpandafterUD@firstoftwo{ }{}%
UD@secondoftwo}{expandafterexpandafterUD@firstoftwo{ }{}UD@firstoftwo}%
}%
%%-----------------------------------------------------------------------------
%% Check whether argument is blank (empty or only spaces):
%%.............................................................................
%% -- Take advantage of the fact that TeX discards space tokens when
%% "fetching" _un_delimited arguments: --
%% UD@CheckWhetherBlank{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case that
%% argument which is to be checked is blank>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is not blank}%
newcommandUD@CheckWhetherBlank[1]{%
romannumeralexpandafterexpandafterexpandafterUD@secondoftwo
expandafterUD@CheckWhetherNullexpandafter{UD@firstoftwo#1{}.}%
}%
%%-----------------------------------------------------------------------------
%% Extract first inner undelimited argument:
%%
%% UD@ExtractFirstArg{ABCDE} yields {A}
%%
%% UD@ExtractFirstArg{{AB}CDE} yields {AB}
%%.............................................................................
newcommandUD@RemoveTillUD@SelDOm{}%
longdefUD@RemoveTillUD@SelDOm#1#2UD@SelDOm{{#1}}%
newcommandUD@ExtractFirstArg[1]{%
romannumeral0%
UD@ExtractFirstArgLoop{#1UD@SelDOm}%
}%
newcommandUD@ExtractFirstArgLoop[1]{%
expandafterUD@CheckWhetherNullexpandafter{UD@firstoftwo{}#1}%
{ #1}%
{expandafterUD@ExtractFirstArgLoopexpandafter{UD@RemoveTillUD@SelDOm#1}}%
}%
%%=============================================================================
%% Process an arbitrary amount of undelimited arguments as
%% a one-column-vector:
%%
%% The macro colvec processes an undelimited argument which in
%% turn consists of an arbitrary amount of undelimited arguments.
%% Each of these undelimited arguments is taken for a row/component
%% of a one-column-vector.
%%
%% You can have spaces between undelimited arguments as (La)TeX does discard
%% spaces that precede undelimited arguments.
%%
%% You can omit braces with undelimited arguments that consist of a
%% single token.
%%-----------------------------------------------------------------------------
newcommandcolvec[1]{%
colvecloop{#1}{}%
}%
newcommandcolvecloop[2]{%
UD@CheckWhetherBlank{#1}{%
begin{pmatrix}#2end{pmatrix}%
}{%
expandafterexpandafterexpandafter
expandafterexpandafterexpandafter
expandafterUD@PassFirstToSecond
expandafterexpandafterexpandafter
expandafterexpandafterexpandafter
expandafter{expandafterexpandafter
expandafterUD@ExchangeUD@ExtractFirstArg{#1}{#2}\}%
{expandaftercolvecloopexpandafter{UD@firstoftwo{}#1}}%
}%
}%
makeatother
begin{document}
verb|$colvec{{a}{b}{c}{d}}$| yields:
$colvec{{a}{b}{c}{d}}$
verb|$colvec{ {a} {b} {c} {d} {e} }$| yields:
$colvec{ {a} {b} {c} {d} {e} }$
verb|$colvec{ {a} {b} {c} {d} {e}fg }$| yields:
$colvec{ {a} {b} {c} {d} {e}fg }$
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%2f2705%2ftypesetting-column-vector%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
9 Answers
9
active
oldest
votes
9 Answers
9
active
oldest
votes
active
oldest
votes
active
oldest
votes
Note that you have extra space around your vector. You should probably using something like (pmatrix
is part of the amsmath
package)
begin{pmatrix}a\bend{pmatrix}
The standard LaTeX newcommand
provides a way to have a single optional argument.
newcommand*colvec[3][]{
begin{pmatrix}ifxrelax#1relaxelse#1\fi#2\#3end{pmatrix}
}
Note that you have to use colvec[a]{b}{c}
if you want three elements or colvec{a}{b}
if you want two.
Update
As per your request in the comments, here's one that takes any number of elements based on the number passed in the first argument.
newcountcolveccount
newcommand*colvec[1]{
globalcolveccount#1
begin{pmatrix}
colvecnext
}
defcolvecnext#1{
#1
globaladvancecolveccount-1
ifnumcolveccount>0
\
expandaftercolvecnext
else
end{pmatrix}
fi
}
You use it exactly as you wanted, colvec{5}{a}{b}{c}{d}{e}
.
Can it be extended to a vector of arbitrary length? say something like: colvec{5}{a}{b}{c}{d}{e} will produce a column vector with 5 entries?
– Dror
Sep 4 '10 at 9:18
16
Yeah, you could do that. Seems like more hassle than it's worth though. How aboutnewcommand*colvec[1]{begin{pmatrix}#1end{pmatrix}
and you writecolvec{a\b\c\d\e}
?
– TH.
Sep 4 '10 at 9:31
Yes!!! This is what I was looking for! Simple and easy to use. Thanks!
– Dror
Sep 4 '10 at 10:03
thesmallpmatrix
frommathtools
may also be handy
– daleif
Apr 21 '12 at 16:36
2
It'spsmallmatrix
notsmallpmatrix
. Just to clear up any mistakes (run into that problem just now).
– Florian Pilz
Mar 9 '13 at 10:14
add a comment |
Note that you have extra space around your vector. You should probably using something like (pmatrix
is part of the amsmath
package)
begin{pmatrix}a\bend{pmatrix}
The standard LaTeX newcommand
provides a way to have a single optional argument.
newcommand*colvec[3][]{
begin{pmatrix}ifxrelax#1relaxelse#1\fi#2\#3end{pmatrix}
}
Note that you have to use colvec[a]{b}{c}
if you want three elements or colvec{a}{b}
if you want two.
Update
As per your request in the comments, here's one that takes any number of elements based on the number passed in the first argument.
newcountcolveccount
newcommand*colvec[1]{
globalcolveccount#1
begin{pmatrix}
colvecnext
}
defcolvecnext#1{
#1
globaladvancecolveccount-1
ifnumcolveccount>0
\
expandaftercolvecnext
else
end{pmatrix}
fi
}
You use it exactly as you wanted, colvec{5}{a}{b}{c}{d}{e}
.
Can it be extended to a vector of arbitrary length? say something like: colvec{5}{a}{b}{c}{d}{e} will produce a column vector with 5 entries?
– Dror
Sep 4 '10 at 9:18
16
Yeah, you could do that. Seems like more hassle than it's worth though. How aboutnewcommand*colvec[1]{begin{pmatrix}#1end{pmatrix}
and you writecolvec{a\b\c\d\e}
?
– TH.
Sep 4 '10 at 9:31
Yes!!! This is what I was looking for! Simple and easy to use. Thanks!
– Dror
Sep 4 '10 at 10:03
thesmallpmatrix
frommathtools
may also be handy
– daleif
Apr 21 '12 at 16:36
2
It'spsmallmatrix
notsmallpmatrix
. Just to clear up any mistakes (run into that problem just now).
– Florian Pilz
Mar 9 '13 at 10:14
add a comment |
Note that you have extra space around your vector. You should probably using something like (pmatrix
is part of the amsmath
package)
begin{pmatrix}a\bend{pmatrix}
The standard LaTeX newcommand
provides a way to have a single optional argument.
newcommand*colvec[3][]{
begin{pmatrix}ifxrelax#1relaxelse#1\fi#2\#3end{pmatrix}
}
Note that you have to use colvec[a]{b}{c}
if you want three elements or colvec{a}{b}
if you want two.
Update
As per your request in the comments, here's one that takes any number of elements based on the number passed in the first argument.
newcountcolveccount
newcommand*colvec[1]{
globalcolveccount#1
begin{pmatrix}
colvecnext
}
defcolvecnext#1{
#1
globaladvancecolveccount-1
ifnumcolveccount>0
\
expandaftercolvecnext
else
end{pmatrix}
fi
}
You use it exactly as you wanted, colvec{5}{a}{b}{c}{d}{e}
.
Note that you have extra space around your vector. You should probably using something like (pmatrix
is part of the amsmath
package)
begin{pmatrix}a\bend{pmatrix}
The standard LaTeX newcommand
provides a way to have a single optional argument.
newcommand*colvec[3][]{
begin{pmatrix}ifxrelax#1relaxelse#1\fi#2\#3end{pmatrix}
}
Note that you have to use colvec[a]{b}{c}
if you want three elements or colvec{a}{b}
if you want two.
Update
As per your request in the comments, here's one that takes any number of elements based on the number passed in the first argument.
newcountcolveccount
newcommand*colvec[1]{
globalcolveccount#1
begin{pmatrix}
colvecnext
}
defcolvecnext#1{
#1
globaladvancecolveccount-1
ifnumcolveccount>0
\
expandaftercolvecnext
else
end{pmatrix}
fi
}
You use it exactly as you wanted, colvec{5}{a}{b}{c}{d}{e}
.
edited Jul 14 '17 at 14:06
samcarter
93.8k7107305
93.8k7107305
answered Sep 3 '10 at 18:27
TH.TH.
48.1k10132199
48.1k10132199
Can it be extended to a vector of arbitrary length? say something like: colvec{5}{a}{b}{c}{d}{e} will produce a column vector with 5 entries?
– Dror
Sep 4 '10 at 9:18
16
Yeah, you could do that. Seems like more hassle than it's worth though. How aboutnewcommand*colvec[1]{begin{pmatrix}#1end{pmatrix}
and you writecolvec{a\b\c\d\e}
?
– TH.
Sep 4 '10 at 9:31
Yes!!! This is what I was looking for! Simple and easy to use. Thanks!
– Dror
Sep 4 '10 at 10:03
thesmallpmatrix
frommathtools
may also be handy
– daleif
Apr 21 '12 at 16:36
2
It'spsmallmatrix
notsmallpmatrix
. Just to clear up any mistakes (run into that problem just now).
– Florian Pilz
Mar 9 '13 at 10:14
add a comment |
Can it be extended to a vector of arbitrary length? say something like: colvec{5}{a}{b}{c}{d}{e} will produce a column vector with 5 entries?
– Dror
Sep 4 '10 at 9:18
16
Yeah, you could do that. Seems like more hassle than it's worth though. How aboutnewcommand*colvec[1]{begin{pmatrix}#1end{pmatrix}
and you writecolvec{a\b\c\d\e}
?
– TH.
Sep 4 '10 at 9:31
Yes!!! This is what I was looking for! Simple and easy to use. Thanks!
– Dror
Sep 4 '10 at 10:03
thesmallpmatrix
frommathtools
may also be handy
– daleif
Apr 21 '12 at 16:36
2
It'spsmallmatrix
notsmallpmatrix
. Just to clear up any mistakes (run into that problem just now).
– Florian Pilz
Mar 9 '13 at 10:14
Can it be extended to a vector of arbitrary length? say something like: colvec{5}{a}{b}{c}{d}{e} will produce a column vector with 5 entries?
– Dror
Sep 4 '10 at 9:18
Can it be extended to a vector of arbitrary length? say something like: colvec{5}{a}{b}{c}{d}{e} will produce a column vector with 5 entries?
– Dror
Sep 4 '10 at 9:18
16
16
Yeah, you could do that. Seems like more hassle than it's worth though. How about
newcommand*colvec[1]{begin{pmatrix}#1end{pmatrix}
and you write colvec{a\b\c\d\e}
?– TH.
Sep 4 '10 at 9:31
Yeah, you could do that. Seems like more hassle than it's worth though. How about
newcommand*colvec[1]{begin{pmatrix}#1end{pmatrix}
and you write colvec{a\b\c\d\e}
?– TH.
Sep 4 '10 at 9:31
Yes!!! This is what I was looking for! Simple and easy to use. Thanks!
– Dror
Sep 4 '10 at 10:03
Yes!!! This is what I was looking for! Simple and easy to use. Thanks!
– Dror
Sep 4 '10 at 10:03
the
smallpmatrix
from mathtools
may also be handy– daleif
Apr 21 '12 at 16:36
the
smallpmatrix
from mathtools
may also be handy– daleif
Apr 21 '12 at 16:36
2
2
It's
psmallmatrix
not smallpmatrix
. Just to clear up any mistakes (run into that problem just now).– Florian Pilz
Mar 9 '13 at 10:14
It's
psmallmatrix
not smallpmatrix
. Just to clear up any mistakes (run into that problem just now).– Florian Pilz
Mar 9 '13 at 10:14
add a comment |
This is a more "TeX" approach. The number of rows is arbitrary. The columns are aligned right by default, but can be c or l as well:
documentclass{article}
makeatletter
newcommand{Spvek}[2][r]{%
gdef@VORNE{1}
left(hskip-arraycolsep%
begin{array}{#1}vekSp@lten{#2}end{array}%
hskip-arraycolsepright)}
defvekSp@lten#1{xvekSp@lten#1;vekL@stLine;}
defvekL@stLine{vekL@stLine}
defxvekSp@lten#1;{deftemp{#1}%
ifxtempvekL@stLine
else
ifnum@VORNE=1gdef@VORNE{0}
else@arraycrfi%
#1%
expandafterxvekSp@lten
fi}
makeatother
begin{document}
[
Spvek{1;-2} quad Spvek[l]{1;-2;3}quad Spvek[c]{1;-2;-3}quadSpvek{1;2;-3;4}
]
end{document}
Output will be:
@percusse How did you crop the picture? I tried, but couldn't find a way. Thank you for cropping.
– Peter Breitfeld
Apr 21 '12 at 20:39
I did it manually using Paint :)
– percusse
Apr 21 '12 at 20:44
@PeterBreitfeld: See How do you crop an attached PDF?
– Werner
Apr 21 '12 at 22:26
+1 Just what I was looking for. But what does Spvek mean?
– Oriol
Mar 16 '13 at 20:17
Turns out to be abb. for spaltenvektor, in german pbreitfeld.de/schule2e.sty
– osolmaz
Nov 6 '13 at 20:13
add a comment |
This is a more "TeX" approach. The number of rows is arbitrary. The columns are aligned right by default, but can be c or l as well:
documentclass{article}
makeatletter
newcommand{Spvek}[2][r]{%
gdef@VORNE{1}
left(hskip-arraycolsep%
begin{array}{#1}vekSp@lten{#2}end{array}%
hskip-arraycolsepright)}
defvekSp@lten#1{xvekSp@lten#1;vekL@stLine;}
defvekL@stLine{vekL@stLine}
defxvekSp@lten#1;{deftemp{#1}%
ifxtempvekL@stLine
else
ifnum@VORNE=1gdef@VORNE{0}
else@arraycrfi%
#1%
expandafterxvekSp@lten
fi}
makeatother
begin{document}
[
Spvek{1;-2} quad Spvek[l]{1;-2;3}quad Spvek[c]{1;-2;-3}quadSpvek{1;2;-3;4}
]
end{document}
Output will be:
@percusse How did you crop the picture? I tried, but couldn't find a way. Thank you for cropping.
– Peter Breitfeld
Apr 21 '12 at 20:39
I did it manually using Paint :)
– percusse
Apr 21 '12 at 20:44
@PeterBreitfeld: See How do you crop an attached PDF?
– Werner
Apr 21 '12 at 22:26
+1 Just what I was looking for. But what does Spvek mean?
– Oriol
Mar 16 '13 at 20:17
Turns out to be abb. for spaltenvektor, in german pbreitfeld.de/schule2e.sty
– osolmaz
Nov 6 '13 at 20:13
add a comment |
This is a more "TeX" approach. The number of rows is arbitrary. The columns are aligned right by default, but can be c or l as well:
documentclass{article}
makeatletter
newcommand{Spvek}[2][r]{%
gdef@VORNE{1}
left(hskip-arraycolsep%
begin{array}{#1}vekSp@lten{#2}end{array}%
hskip-arraycolsepright)}
defvekSp@lten#1{xvekSp@lten#1;vekL@stLine;}
defvekL@stLine{vekL@stLine}
defxvekSp@lten#1;{deftemp{#1}%
ifxtempvekL@stLine
else
ifnum@VORNE=1gdef@VORNE{0}
else@arraycrfi%
#1%
expandafterxvekSp@lten
fi}
makeatother
begin{document}
[
Spvek{1;-2} quad Spvek[l]{1;-2;3}quad Spvek[c]{1;-2;-3}quadSpvek{1;2;-3;4}
]
end{document}
Output will be:
This is a more "TeX" approach. The number of rows is arbitrary. The columns are aligned right by default, but can be c or l as well:
documentclass{article}
makeatletter
newcommand{Spvek}[2][r]{%
gdef@VORNE{1}
left(hskip-arraycolsep%
begin{array}{#1}vekSp@lten{#2}end{array}%
hskip-arraycolsepright)}
defvekSp@lten#1{xvekSp@lten#1;vekL@stLine;}
defvekL@stLine{vekL@stLine}
defxvekSp@lten#1;{deftemp{#1}%
ifxtempvekL@stLine
else
ifnum@VORNE=1gdef@VORNE{0}
else@arraycrfi%
#1%
expandafterxvekSp@lten
fi}
makeatother
begin{document}
[
Spvek{1;-2} quad Spvek[l]{1;-2;3}quad Spvek[c]{1;-2;-3}quadSpvek{1;2;-3;4}
]
end{document}
Output will be:
edited Apr 21 '12 at 20:22
percusse
138k14260497
138k14260497
answered Apr 21 '12 at 20:07
Peter BreitfeldPeter Breitfeld
3,01111312
3,01111312
@percusse How did you crop the picture? I tried, but couldn't find a way. Thank you for cropping.
– Peter Breitfeld
Apr 21 '12 at 20:39
I did it manually using Paint :)
– percusse
Apr 21 '12 at 20:44
@PeterBreitfeld: See How do you crop an attached PDF?
– Werner
Apr 21 '12 at 22:26
+1 Just what I was looking for. But what does Spvek mean?
– Oriol
Mar 16 '13 at 20:17
Turns out to be abb. for spaltenvektor, in german pbreitfeld.de/schule2e.sty
– osolmaz
Nov 6 '13 at 20:13
add a comment |
@percusse How did you crop the picture? I tried, but couldn't find a way. Thank you for cropping.
– Peter Breitfeld
Apr 21 '12 at 20:39
I did it manually using Paint :)
– percusse
Apr 21 '12 at 20:44
@PeterBreitfeld: See How do you crop an attached PDF?
– Werner
Apr 21 '12 at 22:26
+1 Just what I was looking for. But what does Spvek mean?
– Oriol
Mar 16 '13 at 20:17
Turns out to be abb. for spaltenvektor, in german pbreitfeld.de/schule2e.sty
– osolmaz
Nov 6 '13 at 20:13
@percusse How did you crop the picture? I tried, but couldn't find a way. Thank you for cropping.
– Peter Breitfeld
Apr 21 '12 at 20:39
@percusse How did you crop the picture? I tried, but couldn't find a way. Thank you for cropping.
– Peter Breitfeld
Apr 21 '12 at 20:39
I did it manually using Paint :)
– percusse
Apr 21 '12 at 20:44
I did it manually using Paint :)
– percusse
Apr 21 '12 at 20:44
@PeterBreitfeld: See How do you crop an attached PDF?
– Werner
Apr 21 '12 at 22:26
@PeterBreitfeld: See How do you crop an attached PDF?
– Werner
Apr 21 '12 at 22:26
+1 Just what I was looking for. But what does Spvek mean?
– Oriol
Mar 16 '13 at 20:17
+1 Just what I was looking for. But what does Spvek mean?
– Oriol
Mar 16 '13 at 20:17
Turns out to be abb. for spaltenvektor, in german pbreitfeld.de/schule2e.sty
– osolmaz
Nov 6 '13 at 20:13
Turns out to be abb. for spaltenvektor, in german pbreitfeld.de/schule2e.sty
– osolmaz
Nov 6 '13 at 20:13
add a comment |
For vectors with only two elements, or any doublet you want to express in column form, there is a standard LaTeX command in math mode $binom{a}{b}$ or alternatively ${n choose k}$. These look nice with tight vertically lengthened parentheses.
add a comment |
For vectors with only two elements, or any doublet you want to express in column form, there is a standard LaTeX command in math mode $binom{a}{b}$ or alternatively ${n choose k}$. These look nice with tight vertically lengthened parentheses.
add a comment |
For vectors with only two elements, or any doublet you want to express in column form, there is a standard LaTeX command in math mode $binom{a}{b}$ or alternatively ${n choose k}$. These look nice with tight vertically lengthened parentheses.
For vectors with only two elements, or any doublet you want to express in column form, there is a standard LaTeX command in math mode $binom{a}{b}$ or alternatively ${n choose k}$. These look nice with tight vertically lengthened parentheses.
answered May 17 '14 at 12:21
Guillaume BelangerGuillaume Belanger
13824
13824
add a comment |
add a comment |
Since you specified only wanting two or three arguments (not an arbitrary number of them, as others here have given solutions for), you can use the xparse package to define commands with optional braced arguments. Something like (untested)
DeclareDocumentCommand colvec {mmg} {%
IfNoValueTF #3 {%
twocolvec {#1}{#2}
}{%
threecolvec {#1}{#2}{#3}
}%
}
Where the two intermediate functions (defined as appropriate) typeset the array as appropriate.
Does this means that I have to define separately the function twocolvec and threecolvec?
– Dror
Sep 4 '10 at 9:17
add a comment |
Since you specified only wanting two or three arguments (not an arbitrary number of them, as others here have given solutions for), you can use the xparse package to define commands with optional braced arguments. Something like (untested)
DeclareDocumentCommand colvec {mmg} {%
IfNoValueTF #3 {%
twocolvec {#1}{#2}
}{%
threecolvec {#1}{#2}{#3}
}%
}
Where the two intermediate functions (defined as appropriate) typeset the array as appropriate.
Does this means that I have to define separately the function twocolvec and threecolvec?
– Dror
Sep 4 '10 at 9:17
add a comment |
Since you specified only wanting two or three arguments (not an arbitrary number of them, as others here have given solutions for), you can use the xparse package to define commands with optional braced arguments. Something like (untested)
DeclareDocumentCommand colvec {mmg} {%
IfNoValueTF #3 {%
twocolvec {#1}{#2}
}{%
threecolvec {#1}{#2}{#3}
}%
}
Where the two intermediate functions (defined as appropriate) typeset the array as appropriate.
Since you specified only wanting two or three arguments (not an arbitrary number of them, as others here have given solutions for), you can use the xparse package to define commands with optional braced arguments. Something like (untested)
DeclareDocumentCommand colvec {mmg} {%
IfNoValueTF #3 {%
twocolvec {#1}{#2}
}{%
threecolvec {#1}{#2}{#3}
}%
}
Where the two intermediate functions (defined as appropriate) typeset the array as appropriate.
edited Sep 6 '18 at 14:30
answered Sep 3 '10 at 16:34
Will RobertsonWill Robertson
59.1k13157202
59.1k13157202
Does this means that I have to define separately the function twocolvec and threecolvec?
– Dror
Sep 4 '10 at 9:17
add a comment |
Does this means that I have to define separately the function twocolvec and threecolvec?
– Dror
Sep 4 '10 at 9:17
Does this means that I have to define separately the function twocolvec and threecolvec?
– Dror
Sep 4 '10 at 9:17
Does this means that I have to define separately the function twocolvec and threecolvec?
– Dror
Sep 4 '10 at 9:17
add a comment |
I would to supplement the solution above about Spvek by Peter B.
Yes, it is a more "TeX" approach but pure "TeX" approach is in two lines only:
defspvec#1{left(vcenter{halign{hfil$##$hfilcr spvecA#1;;}}right)}
defspvecA#1;{if;#1;else #1cr expandafter spvecA fi}
$spvec{1;2;3} + spvec{1;2;-3;4} + spvec{1;2}$
This solution will be work in LaTeX too because only TeX primitives are used here.
Does anyone care to elaborate on this code? I like it and want to modify it, but anything I attempt will fail. What is going on here$##$
?
– fborchers
yesterday
add a comment |
I would to supplement the solution above about Spvek by Peter B.
Yes, it is a more "TeX" approach but pure "TeX" approach is in two lines only:
defspvec#1{left(vcenter{halign{hfil$##$hfilcr spvecA#1;;}}right)}
defspvecA#1;{if;#1;else #1cr expandafter spvecA fi}
$spvec{1;2;3} + spvec{1;2;-3;4} + spvec{1;2}$
This solution will be work in LaTeX too because only TeX primitives are used here.
Does anyone care to elaborate on this code? I like it and want to modify it, but anything I attempt will fail. What is going on here$##$
?
– fborchers
yesterday
add a comment |
I would to supplement the solution above about Spvek by Peter B.
Yes, it is a more "TeX" approach but pure "TeX" approach is in two lines only:
defspvec#1{left(vcenter{halign{hfil$##$hfilcr spvecA#1;;}}right)}
defspvecA#1;{if;#1;else #1cr expandafter spvecA fi}
$spvec{1;2;3} + spvec{1;2;-3;4} + spvec{1;2}$
This solution will be work in LaTeX too because only TeX primitives are used here.
I would to supplement the solution above about Spvek by Peter B.
Yes, it is a more "TeX" approach but pure "TeX" approach is in two lines only:
defspvec#1{left(vcenter{halign{hfil$##$hfilcr spvecA#1;;}}right)}
defspvecA#1;{if;#1;else #1cr expandafter spvecA fi}
$spvec{1;2;3} + spvec{1;2;-3;4} + spvec{1;2}$
This solution will be work in LaTeX too because only TeX primitives are used here.
answered May 17 '14 at 17:13
wipetwipet
35.4k4983
35.4k4983
Does anyone care to elaborate on this code? I like it and want to modify it, but anything I attempt will fail. What is going on here$##$
?
– fborchers
yesterday
add a comment |
Does anyone care to elaborate on this code? I like it and want to modify it, but anything I attempt will fail. What is going on here$##$
?
– fborchers
yesterday
Does anyone care to elaborate on this code? I like it and want to modify it, but anything I attempt will fail. What is going on here
$##$
?– fborchers
yesterday
Does anyone care to elaborate on this code? I like it and want to modify it, but anything I attempt will fail. What is going on here
$##$
?– fborchers
yesterday
add a comment |
Here is my KISS-like solution (which is just a wrapper for pmatrix
from the amsmath
package, inspired by Garrys answer):
newcommand{myvec}[1]{ensuremath{begin{pmatrix}#1end{pmatrix}}}
Usage:
myvec{x\y\z}
The good thing is, you don't need to specify a number of elements or anything. You can just add more elements with \
. It also looks tidier in the tex-file then using the pmatrix
environment itself.
You can also use it for row-vectors:
myvec{a&b&c}
(For completion: Matrices work aswell, obviously: myvec{a&b \ c&d}
)
add a comment |
Here is my KISS-like solution (which is just a wrapper for pmatrix
from the amsmath
package, inspired by Garrys answer):
newcommand{myvec}[1]{ensuremath{begin{pmatrix}#1end{pmatrix}}}
Usage:
myvec{x\y\z}
The good thing is, you don't need to specify a number of elements or anything. You can just add more elements with \
. It also looks tidier in the tex-file then using the pmatrix
environment itself.
You can also use it for row-vectors:
myvec{a&b&c}
(For completion: Matrices work aswell, obviously: myvec{a&b \ c&d}
)
add a comment |
Here is my KISS-like solution (which is just a wrapper for pmatrix
from the amsmath
package, inspired by Garrys answer):
newcommand{myvec}[1]{ensuremath{begin{pmatrix}#1end{pmatrix}}}
Usage:
myvec{x\y\z}
The good thing is, you don't need to specify a number of elements or anything. You can just add more elements with \
. It also looks tidier in the tex-file then using the pmatrix
environment itself.
You can also use it for row-vectors:
myvec{a&b&c}
(For completion: Matrices work aswell, obviously: myvec{a&b \ c&d}
)
Here is my KISS-like solution (which is just a wrapper for pmatrix
from the amsmath
package, inspired by Garrys answer):
newcommand{myvec}[1]{ensuremath{begin{pmatrix}#1end{pmatrix}}}
Usage:
myvec{x\y\z}
The good thing is, you don't need to specify a number of elements or anything. You can just add more elements with \
. It also looks tidier in the tex-file then using the pmatrix
environment itself.
You can also use it for row-vectors:
myvec{a&b&c}
(For completion: Matrices work aswell, obviously: myvec{a&b \ c&d}
)
edited May 18 '17 at 7:54
answered May 17 '17 at 14:08
n4pKn4pK
836
836
add a comment |
add a comment |
Years later and not very tex-y, but for some reason I really wanted to use commas as separators and ended up putting together the following:
usepackage{iftex}
RequireLuaTeX
usepackage{amsmath}
usepackage{luacode}
begin{luacode*}
mycolvec = { }
function mycolvec.replace(input)
tex.sprint(
"\ensuremath{\begin{pmatrix}"
.. string.gsub(input, ",", " \\ ")
.. "\end{pmatrix}}")
end
end{luacode*}
defcolvec#1{directlua{mycolvec.replace("#1")}}
Which, when added to the header, allows you to write out column vectors like this:
colvec{1, 2, 3}
colvec{8,6,7,5,3,0,9}
This requires that you compile your tex with lualatex instead of xetex or pdftex, but that shouldn't affect the rest of your document.
The seperator can be changed to any arbitrary character by changing the ","
on the .. string.gsub(...
line.
EDIT:
This method breaks when entering tokens (i.e. colvec{1 cdot 2, 2 cdot 3}
), for the reasons described here. As such I'll recommend egreg's answer on a related question, which provides the functionality I claim here without the same problem.
Welcome to TeX.Se.
– CampanIgnis
Sep 6 '18 at 1:29
add a comment |
Years later and not very tex-y, but for some reason I really wanted to use commas as separators and ended up putting together the following:
usepackage{iftex}
RequireLuaTeX
usepackage{amsmath}
usepackage{luacode}
begin{luacode*}
mycolvec = { }
function mycolvec.replace(input)
tex.sprint(
"\ensuremath{\begin{pmatrix}"
.. string.gsub(input, ",", " \\ ")
.. "\end{pmatrix}}")
end
end{luacode*}
defcolvec#1{directlua{mycolvec.replace("#1")}}
Which, when added to the header, allows you to write out column vectors like this:
colvec{1, 2, 3}
colvec{8,6,7,5,3,0,9}
This requires that you compile your tex with lualatex instead of xetex or pdftex, but that shouldn't affect the rest of your document.
The seperator can be changed to any arbitrary character by changing the ","
on the .. string.gsub(...
line.
EDIT:
This method breaks when entering tokens (i.e. colvec{1 cdot 2, 2 cdot 3}
), for the reasons described here. As such I'll recommend egreg's answer on a related question, which provides the functionality I claim here without the same problem.
Welcome to TeX.Se.
– CampanIgnis
Sep 6 '18 at 1:29
add a comment |
Years later and not very tex-y, but for some reason I really wanted to use commas as separators and ended up putting together the following:
usepackage{iftex}
RequireLuaTeX
usepackage{amsmath}
usepackage{luacode}
begin{luacode*}
mycolvec = { }
function mycolvec.replace(input)
tex.sprint(
"\ensuremath{\begin{pmatrix}"
.. string.gsub(input, ",", " \\ ")
.. "\end{pmatrix}}")
end
end{luacode*}
defcolvec#1{directlua{mycolvec.replace("#1")}}
Which, when added to the header, allows you to write out column vectors like this:
colvec{1, 2, 3}
colvec{8,6,7,5,3,0,9}
This requires that you compile your tex with lualatex instead of xetex or pdftex, but that shouldn't affect the rest of your document.
The seperator can be changed to any arbitrary character by changing the ","
on the .. string.gsub(...
line.
EDIT:
This method breaks when entering tokens (i.e. colvec{1 cdot 2, 2 cdot 3}
), for the reasons described here. As such I'll recommend egreg's answer on a related question, which provides the functionality I claim here without the same problem.
Years later and not very tex-y, but for some reason I really wanted to use commas as separators and ended up putting together the following:
usepackage{iftex}
RequireLuaTeX
usepackage{amsmath}
usepackage{luacode}
begin{luacode*}
mycolvec = { }
function mycolvec.replace(input)
tex.sprint(
"\ensuremath{\begin{pmatrix}"
.. string.gsub(input, ",", " \\ ")
.. "\end{pmatrix}}")
end
end{luacode*}
defcolvec#1{directlua{mycolvec.replace("#1")}}
Which, when added to the header, allows you to write out column vectors like this:
colvec{1, 2, 3}
colvec{8,6,7,5,3,0,9}
This requires that you compile your tex with lualatex instead of xetex or pdftex, but that shouldn't affect the rest of your document.
The seperator can be changed to any arbitrary character by changing the ","
on the .. string.gsub(...
line.
EDIT:
This method breaks when entering tokens (i.e. colvec{1 cdot 2, 2 cdot 3}
), for the reasons described here. As such I'll recommend egreg's answer on a related question, which provides the functionality I claim here without the same problem.
edited Sep 7 '18 at 3:40
answered Sep 6 '18 at 0:28
Your FinYour Fin
212
212
Welcome to TeX.Se.
– CampanIgnis
Sep 6 '18 at 1:29
add a comment |
Welcome to TeX.Se.
– CampanIgnis
Sep 6 '18 at 1:29
Welcome to TeX.Se.
– CampanIgnis
Sep 6 '18 at 1:29
Welcome to TeX.Se.
– CampanIgnis
Sep 6 '18 at 1:29
add a comment |
This post presents another possible approach. It improves on this earlier post above. The idea is to use a similar plain TeX mechanism, but wrap it up in amsmath
s high level pmatrix
environment. This helps with fractions for example. The interface with parentheses is the same as used by PSTricks. Here is a working example:
documentclass[margin=2pt]{standalone}
usepackage{amsmath}
makeatletter
defvector(#1){%
mathchoice%
{pmatrix@i{vector@i#1,,}}%
{pmatrix@ii{vector@i#1,,}}%
{}% scriptstyle too small,
{}% ss style too small.
}
defvector@i#1,{if,#1,else{#1}crexpandaftervector@ifi}
defpmatrix@i#1{begin{pmatrix}#1end{pmatrix}}
defpmatrix@ii#1{left(!begin{smallmatrix}#1end{smallmatrix}!right)}
makeatother
begin{document}
$displaystylevector(-3,+4,5)$ and $vector(-3,+4,5)$
end{document}
When typesetting vectors with lots of fractions it is advisable to increase vertical spacing with:
renewcommand{arraystretch}{1.1}% stretch value 1.1 for example
Because the macros make use of the @i
notation the code will have to be placed inside at makeatletter
- makeatother
wrapping before document begins.
See here for a similar solution for row vectors.
@PhelypeOleinik: done.
– fborchers
8 hours ago
add a comment |
This post presents another possible approach. It improves on this earlier post above. The idea is to use a similar plain TeX mechanism, but wrap it up in amsmath
s high level pmatrix
environment. This helps with fractions for example. The interface with parentheses is the same as used by PSTricks. Here is a working example:
documentclass[margin=2pt]{standalone}
usepackage{amsmath}
makeatletter
defvector(#1){%
mathchoice%
{pmatrix@i{vector@i#1,,}}%
{pmatrix@ii{vector@i#1,,}}%
{}% scriptstyle too small,
{}% ss style too small.
}
defvector@i#1,{if,#1,else{#1}crexpandaftervector@ifi}
defpmatrix@i#1{begin{pmatrix}#1end{pmatrix}}
defpmatrix@ii#1{left(!begin{smallmatrix}#1end{smallmatrix}!right)}
makeatother
begin{document}
$displaystylevector(-3,+4,5)$ and $vector(-3,+4,5)$
end{document}
When typesetting vectors with lots of fractions it is advisable to increase vertical spacing with:
renewcommand{arraystretch}{1.1}% stretch value 1.1 for example
Because the macros make use of the @i
notation the code will have to be placed inside at makeatletter
- makeatother
wrapping before document begins.
See here for a similar solution for row vectors.
@PhelypeOleinik: done.
– fborchers
8 hours ago
add a comment |
This post presents another possible approach. It improves on this earlier post above. The idea is to use a similar plain TeX mechanism, but wrap it up in amsmath
s high level pmatrix
environment. This helps with fractions for example. The interface with parentheses is the same as used by PSTricks. Here is a working example:
documentclass[margin=2pt]{standalone}
usepackage{amsmath}
makeatletter
defvector(#1){%
mathchoice%
{pmatrix@i{vector@i#1,,}}%
{pmatrix@ii{vector@i#1,,}}%
{}% scriptstyle too small,
{}% ss style too small.
}
defvector@i#1,{if,#1,else{#1}crexpandaftervector@ifi}
defpmatrix@i#1{begin{pmatrix}#1end{pmatrix}}
defpmatrix@ii#1{left(!begin{smallmatrix}#1end{smallmatrix}!right)}
makeatother
begin{document}
$displaystylevector(-3,+4,5)$ and $vector(-3,+4,5)$
end{document}
When typesetting vectors with lots of fractions it is advisable to increase vertical spacing with:
renewcommand{arraystretch}{1.1}% stretch value 1.1 for example
Because the macros make use of the @i
notation the code will have to be placed inside at makeatletter
- makeatother
wrapping before document begins.
See here for a similar solution for row vectors.
This post presents another possible approach. It improves on this earlier post above. The idea is to use a similar plain TeX mechanism, but wrap it up in amsmath
s high level pmatrix
environment. This helps with fractions for example. The interface with parentheses is the same as used by PSTricks. Here is a working example:
documentclass[margin=2pt]{standalone}
usepackage{amsmath}
makeatletter
defvector(#1){%
mathchoice%
{pmatrix@i{vector@i#1,,}}%
{pmatrix@ii{vector@i#1,,}}%
{}% scriptstyle too small,
{}% ss style too small.
}
defvector@i#1,{if,#1,else{#1}crexpandaftervector@ifi}
defpmatrix@i#1{begin{pmatrix}#1end{pmatrix}}
defpmatrix@ii#1{left(!begin{smallmatrix}#1end{smallmatrix}!right)}
makeatother
begin{document}
$displaystylevector(-3,+4,5)$ and $vector(-3,+4,5)$
end{document}
When typesetting vectors with lots of fractions it is advisable to increase vertical spacing with:
renewcommand{arraystretch}{1.1}% stretch value 1.1 for example
Because the macros make use of the @i
notation the code will have to be placed inside at makeatletter
- makeatother
wrapping before document begins.
See here for a similar solution for row vectors.
edited 7 hours ago
answered 8 hours ago
fborchersfborchers
839
839
@PhelypeOleinik: done.
– fborchers
8 hours ago
add a comment |
@PhelypeOleinik: done.
– fborchers
8 hours ago
@PhelypeOleinik: done.
– fborchers
8 hours ago
@PhelypeOleinik: done.
– fborchers
8 hours ago
add a comment |
I can offer a macro colvec
within whose argument you can supply an arbitrary amount of undelimited arguments whereof each one will be taken for a component of the one-column-vector:
documentclass{article}
usepackage{amsmath}
makeatletter
%%=============================================================================
%% Paraphernalia:
%% UD@firstoftwo, UD@secondoftwo, UD@Exchange, UD@PassFirstToSecond,
%% UD@CheckWhetherNull, UD@CheckWhetherBlank, UD@ExtractFirstArg
%%=============================================================================
newcommandUD@firstoftwo[2]{#1}%
newcommandUD@secondoftwo[2]{#2}%
newcommandUD@Exchange[2]{#2#1}%
newcommandUD@PassFirstToSecond[2]{#2{#1}}%
%%-----------------------------------------------------------------------------
%% Check whether argument is empty:
%%.............................................................................
%% UD@CheckWhetherNull{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is empty>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is not empty>}%
%%
%% The gist of this macro comes from Robert R. Schneck's ifempty-macro:
%% <https://groups.google.com/forum/#!original/comp.text.tex/kuOEIQIrElc/lUg37FmhA74J>
newcommandUD@CheckWhetherNull[1]{%
romannumeral0expandafterUD@secondoftwostring{expandafter
UD@secondoftwoexpandafter{expandafter{string#1}expandafter
UD@secondoftwostring}expandafterUD@firstoftwoexpandafter{expandafter
UD@secondoftwostring}expandafterexpandafterUD@firstoftwo{ }{}%
UD@secondoftwo}{expandafterexpandafterUD@firstoftwo{ }{}UD@firstoftwo}%
}%
%%-----------------------------------------------------------------------------
%% Check whether argument is blank (empty or only spaces):
%%.............................................................................
%% -- Take advantage of the fact that TeX discards space tokens when
%% "fetching" _un_delimited arguments: --
%% UD@CheckWhetherBlank{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case that
%% argument which is to be checked is blank>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is not blank}%
newcommandUD@CheckWhetherBlank[1]{%
romannumeralexpandafterexpandafterexpandafterUD@secondoftwo
expandafterUD@CheckWhetherNullexpandafter{UD@firstoftwo#1{}.}%
}%
%%-----------------------------------------------------------------------------
%% Extract first inner undelimited argument:
%%
%% UD@ExtractFirstArg{ABCDE} yields {A}
%%
%% UD@ExtractFirstArg{{AB}CDE} yields {AB}
%%.............................................................................
newcommandUD@RemoveTillUD@SelDOm{}%
longdefUD@RemoveTillUD@SelDOm#1#2UD@SelDOm{{#1}}%
newcommandUD@ExtractFirstArg[1]{%
romannumeral0%
UD@ExtractFirstArgLoop{#1UD@SelDOm}%
}%
newcommandUD@ExtractFirstArgLoop[1]{%
expandafterUD@CheckWhetherNullexpandafter{UD@firstoftwo{}#1}%
{ #1}%
{expandafterUD@ExtractFirstArgLoopexpandafter{UD@RemoveTillUD@SelDOm#1}}%
}%
%%=============================================================================
%% Process an arbitrary amount of undelimited arguments as
%% a one-column-vector:
%%
%% The macro colvec processes an undelimited argument which in
%% turn consists of an arbitrary amount of undelimited arguments.
%% Each of these undelimited arguments is taken for a row/component
%% of a one-column-vector.
%%
%% You can have spaces between undelimited arguments as (La)TeX does discard
%% spaces that precede undelimited arguments.
%%
%% You can omit braces with undelimited arguments that consist of a
%% single token.
%%-----------------------------------------------------------------------------
newcommandcolvec[1]{%
colvecloop{#1}{}%
}%
newcommandcolvecloop[2]{%
UD@CheckWhetherBlank{#1}{%
begin{pmatrix}#2end{pmatrix}%
}{%
expandafterexpandafterexpandafter
expandafterexpandafterexpandafter
expandafterUD@PassFirstToSecond
expandafterexpandafterexpandafter
expandafterexpandafterexpandafter
expandafter{expandafterexpandafter
expandafterUD@ExchangeUD@ExtractFirstArg{#1}{#2}\}%
{expandaftercolvecloopexpandafter{UD@firstoftwo{}#1}}%
}%
}%
makeatother
begin{document}
verb|$colvec{{a}{b}{c}{d}}$| yields:
$colvec{{a}{b}{c}{d}}$
verb|$colvec{ {a} {b} {c} {d} {e} }$| yields:
$colvec{ {a} {b} {c} {d} {e} }$
verb|$colvec{ {a} {b} {c} {d} {e}fg }$| yields:
$colvec{ {a} {b} {c} {d} {e}fg }$
end{document}
add a comment |
I can offer a macro colvec
within whose argument you can supply an arbitrary amount of undelimited arguments whereof each one will be taken for a component of the one-column-vector:
documentclass{article}
usepackage{amsmath}
makeatletter
%%=============================================================================
%% Paraphernalia:
%% UD@firstoftwo, UD@secondoftwo, UD@Exchange, UD@PassFirstToSecond,
%% UD@CheckWhetherNull, UD@CheckWhetherBlank, UD@ExtractFirstArg
%%=============================================================================
newcommandUD@firstoftwo[2]{#1}%
newcommandUD@secondoftwo[2]{#2}%
newcommandUD@Exchange[2]{#2#1}%
newcommandUD@PassFirstToSecond[2]{#2{#1}}%
%%-----------------------------------------------------------------------------
%% Check whether argument is empty:
%%.............................................................................
%% UD@CheckWhetherNull{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is empty>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is not empty>}%
%%
%% The gist of this macro comes from Robert R. Schneck's ifempty-macro:
%% <https://groups.google.com/forum/#!original/comp.text.tex/kuOEIQIrElc/lUg37FmhA74J>
newcommandUD@CheckWhetherNull[1]{%
romannumeral0expandafterUD@secondoftwostring{expandafter
UD@secondoftwoexpandafter{expandafter{string#1}expandafter
UD@secondoftwostring}expandafterUD@firstoftwoexpandafter{expandafter
UD@secondoftwostring}expandafterexpandafterUD@firstoftwo{ }{}%
UD@secondoftwo}{expandafterexpandafterUD@firstoftwo{ }{}UD@firstoftwo}%
}%
%%-----------------------------------------------------------------------------
%% Check whether argument is blank (empty or only spaces):
%%.............................................................................
%% -- Take advantage of the fact that TeX discards space tokens when
%% "fetching" _un_delimited arguments: --
%% UD@CheckWhetherBlank{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case that
%% argument which is to be checked is blank>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is not blank}%
newcommandUD@CheckWhetherBlank[1]{%
romannumeralexpandafterexpandafterexpandafterUD@secondoftwo
expandafterUD@CheckWhetherNullexpandafter{UD@firstoftwo#1{}.}%
}%
%%-----------------------------------------------------------------------------
%% Extract first inner undelimited argument:
%%
%% UD@ExtractFirstArg{ABCDE} yields {A}
%%
%% UD@ExtractFirstArg{{AB}CDE} yields {AB}
%%.............................................................................
newcommandUD@RemoveTillUD@SelDOm{}%
longdefUD@RemoveTillUD@SelDOm#1#2UD@SelDOm{{#1}}%
newcommandUD@ExtractFirstArg[1]{%
romannumeral0%
UD@ExtractFirstArgLoop{#1UD@SelDOm}%
}%
newcommandUD@ExtractFirstArgLoop[1]{%
expandafterUD@CheckWhetherNullexpandafter{UD@firstoftwo{}#1}%
{ #1}%
{expandafterUD@ExtractFirstArgLoopexpandafter{UD@RemoveTillUD@SelDOm#1}}%
}%
%%=============================================================================
%% Process an arbitrary amount of undelimited arguments as
%% a one-column-vector:
%%
%% The macro colvec processes an undelimited argument which in
%% turn consists of an arbitrary amount of undelimited arguments.
%% Each of these undelimited arguments is taken for a row/component
%% of a one-column-vector.
%%
%% You can have spaces between undelimited arguments as (La)TeX does discard
%% spaces that precede undelimited arguments.
%%
%% You can omit braces with undelimited arguments that consist of a
%% single token.
%%-----------------------------------------------------------------------------
newcommandcolvec[1]{%
colvecloop{#1}{}%
}%
newcommandcolvecloop[2]{%
UD@CheckWhetherBlank{#1}{%
begin{pmatrix}#2end{pmatrix}%
}{%
expandafterexpandafterexpandafter
expandafterexpandafterexpandafter
expandafterUD@PassFirstToSecond
expandafterexpandafterexpandafter
expandafterexpandafterexpandafter
expandafter{expandafterexpandafter
expandafterUD@ExchangeUD@ExtractFirstArg{#1}{#2}\}%
{expandaftercolvecloopexpandafter{UD@firstoftwo{}#1}}%
}%
}%
makeatother
begin{document}
verb|$colvec{{a}{b}{c}{d}}$| yields:
$colvec{{a}{b}{c}{d}}$
verb|$colvec{ {a} {b} {c} {d} {e} }$| yields:
$colvec{ {a} {b} {c} {d} {e} }$
verb|$colvec{ {a} {b} {c} {d} {e}fg }$| yields:
$colvec{ {a} {b} {c} {d} {e}fg }$
end{document}
add a comment |
I can offer a macro colvec
within whose argument you can supply an arbitrary amount of undelimited arguments whereof each one will be taken for a component of the one-column-vector:
documentclass{article}
usepackage{amsmath}
makeatletter
%%=============================================================================
%% Paraphernalia:
%% UD@firstoftwo, UD@secondoftwo, UD@Exchange, UD@PassFirstToSecond,
%% UD@CheckWhetherNull, UD@CheckWhetherBlank, UD@ExtractFirstArg
%%=============================================================================
newcommandUD@firstoftwo[2]{#1}%
newcommandUD@secondoftwo[2]{#2}%
newcommandUD@Exchange[2]{#2#1}%
newcommandUD@PassFirstToSecond[2]{#2{#1}}%
%%-----------------------------------------------------------------------------
%% Check whether argument is empty:
%%.............................................................................
%% UD@CheckWhetherNull{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is empty>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is not empty>}%
%%
%% The gist of this macro comes from Robert R. Schneck's ifempty-macro:
%% <https://groups.google.com/forum/#!original/comp.text.tex/kuOEIQIrElc/lUg37FmhA74J>
newcommandUD@CheckWhetherNull[1]{%
romannumeral0expandafterUD@secondoftwostring{expandafter
UD@secondoftwoexpandafter{expandafter{string#1}expandafter
UD@secondoftwostring}expandafterUD@firstoftwoexpandafter{expandafter
UD@secondoftwostring}expandafterexpandafterUD@firstoftwo{ }{}%
UD@secondoftwo}{expandafterexpandafterUD@firstoftwo{ }{}UD@firstoftwo}%
}%
%%-----------------------------------------------------------------------------
%% Check whether argument is blank (empty or only spaces):
%%.............................................................................
%% -- Take advantage of the fact that TeX discards space tokens when
%% "fetching" _un_delimited arguments: --
%% UD@CheckWhetherBlank{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case that
%% argument which is to be checked is blank>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is not blank}%
newcommandUD@CheckWhetherBlank[1]{%
romannumeralexpandafterexpandafterexpandafterUD@secondoftwo
expandafterUD@CheckWhetherNullexpandafter{UD@firstoftwo#1{}.}%
}%
%%-----------------------------------------------------------------------------
%% Extract first inner undelimited argument:
%%
%% UD@ExtractFirstArg{ABCDE} yields {A}
%%
%% UD@ExtractFirstArg{{AB}CDE} yields {AB}
%%.............................................................................
newcommandUD@RemoveTillUD@SelDOm{}%
longdefUD@RemoveTillUD@SelDOm#1#2UD@SelDOm{{#1}}%
newcommandUD@ExtractFirstArg[1]{%
romannumeral0%
UD@ExtractFirstArgLoop{#1UD@SelDOm}%
}%
newcommandUD@ExtractFirstArgLoop[1]{%
expandafterUD@CheckWhetherNullexpandafter{UD@firstoftwo{}#1}%
{ #1}%
{expandafterUD@ExtractFirstArgLoopexpandafter{UD@RemoveTillUD@SelDOm#1}}%
}%
%%=============================================================================
%% Process an arbitrary amount of undelimited arguments as
%% a one-column-vector:
%%
%% The macro colvec processes an undelimited argument which in
%% turn consists of an arbitrary amount of undelimited arguments.
%% Each of these undelimited arguments is taken for a row/component
%% of a one-column-vector.
%%
%% You can have spaces between undelimited arguments as (La)TeX does discard
%% spaces that precede undelimited arguments.
%%
%% You can omit braces with undelimited arguments that consist of a
%% single token.
%%-----------------------------------------------------------------------------
newcommandcolvec[1]{%
colvecloop{#1}{}%
}%
newcommandcolvecloop[2]{%
UD@CheckWhetherBlank{#1}{%
begin{pmatrix}#2end{pmatrix}%
}{%
expandafterexpandafterexpandafter
expandafterexpandafterexpandafter
expandafterUD@PassFirstToSecond
expandafterexpandafterexpandafter
expandafterexpandafterexpandafter
expandafter{expandafterexpandafter
expandafterUD@ExchangeUD@ExtractFirstArg{#1}{#2}\}%
{expandaftercolvecloopexpandafter{UD@firstoftwo{}#1}}%
}%
}%
makeatother
begin{document}
verb|$colvec{{a}{b}{c}{d}}$| yields:
$colvec{{a}{b}{c}{d}}$
verb|$colvec{ {a} {b} {c} {d} {e} }$| yields:
$colvec{ {a} {b} {c} {d} {e} }$
verb|$colvec{ {a} {b} {c} {d} {e}fg }$| yields:
$colvec{ {a} {b} {c} {d} {e}fg }$
end{document}
I can offer a macro colvec
within whose argument you can supply an arbitrary amount of undelimited arguments whereof each one will be taken for a component of the one-column-vector:
documentclass{article}
usepackage{amsmath}
makeatletter
%%=============================================================================
%% Paraphernalia:
%% UD@firstoftwo, UD@secondoftwo, UD@Exchange, UD@PassFirstToSecond,
%% UD@CheckWhetherNull, UD@CheckWhetherBlank, UD@ExtractFirstArg
%%=============================================================================
newcommandUD@firstoftwo[2]{#1}%
newcommandUD@secondoftwo[2]{#2}%
newcommandUD@Exchange[2]{#2#1}%
newcommandUD@PassFirstToSecond[2]{#2{#1}}%
%%-----------------------------------------------------------------------------
%% Check whether argument is empty:
%%.............................................................................
%% UD@CheckWhetherNull{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is empty>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is not empty>}%
%%
%% The gist of this macro comes from Robert R. Schneck's ifempty-macro:
%% <https://groups.google.com/forum/#!original/comp.text.tex/kuOEIQIrElc/lUg37FmhA74J>
newcommandUD@CheckWhetherNull[1]{%
romannumeral0expandafterUD@secondoftwostring{expandafter
UD@secondoftwoexpandafter{expandafter{string#1}expandafter
UD@secondoftwostring}expandafterUD@firstoftwoexpandafter{expandafter
UD@secondoftwostring}expandafterexpandafterUD@firstoftwo{ }{}%
UD@secondoftwo}{expandafterexpandafterUD@firstoftwo{ }{}UD@firstoftwo}%
}%
%%-----------------------------------------------------------------------------
%% Check whether argument is blank (empty or only spaces):
%%.............................................................................
%% -- Take advantage of the fact that TeX discards space tokens when
%% "fetching" _un_delimited arguments: --
%% UD@CheckWhetherBlank{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case that
%% argument which is to be checked is blank>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is not blank}%
newcommandUD@CheckWhetherBlank[1]{%
romannumeralexpandafterexpandafterexpandafterUD@secondoftwo
expandafterUD@CheckWhetherNullexpandafter{UD@firstoftwo#1{}.}%
}%
%%-----------------------------------------------------------------------------
%% Extract first inner undelimited argument:
%%
%% UD@ExtractFirstArg{ABCDE} yields {A}
%%
%% UD@ExtractFirstArg{{AB}CDE} yields {AB}
%%.............................................................................
newcommandUD@RemoveTillUD@SelDOm{}%
longdefUD@RemoveTillUD@SelDOm#1#2UD@SelDOm{{#1}}%
newcommandUD@ExtractFirstArg[1]{%
romannumeral0%
UD@ExtractFirstArgLoop{#1UD@SelDOm}%
}%
newcommandUD@ExtractFirstArgLoop[1]{%
expandafterUD@CheckWhetherNullexpandafter{UD@firstoftwo{}#1}%
{ #1}%
{expandafterUD@ExtractFirstArgLoopexpandafter{UD@RemoveTillUD@SelDOm#1}}%
}%
%%=============================================================================
%% Process an arbitrary amount of undelimited arguments as
%% a one-column-vector:
%%
%% The macro colvec processes an undelimited argument which in
%% turn consists of an arbitrary amount of undelimited arguments.
%% Each of these undelimited arguments is taken for a row/component
%% of a one-column-vector.
%%
%% You can have spaces between undelimited arguments as (La)TeX does discard
%% spaces that precede undelimited arguments.
%%
%% You can omit braces with undelimited arguments that consist of a
%% single token.
%%-----------------------------------------------------------------------------
newcommandcolvec[1]{%
colvecloop{#1}{}%
}%
newcommandcolvecloop[2]{%
UD@CheckWhetherBlank{#1}{%
begin{pmatrix}#2end{pmatrix}%
}{%
expandafterexpandafterexpandafter
expandafterexpandafterexpandafter
expandafterUD@PassFirstToSecond
expandafterexpandafterexpandafter
expandafterexpandafterexpandafter
expandafter{expandafterexpandafter
expandafterUD@ExchangeUD@ExtractFirstArg{#1}{#2}\}%
{expandaftercolvecloopexpandafter{UD@firstoftwo{}#1}}%
}%
}%
makeatother
begin{document}
verb|$colvec{{a}{b}{c}{d}}$| yields:
$colvec{{a}{b}{c}{d}}$
verb|$colvec{ {a} {b} {c} {d} {e} }$| yields:
$colvec{ {a} {b} {c} {d} {e} }$
verb|$colvec{ {a} {b} {c} {d} {e}fg }$| yields:
$colvec{ {a} {b} {c} {d} {e}fg }$
end{document}
answered Sep 6 '18 at 10:52
Ulrich DiezUlrich Diez
5,550620
5,550620
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%2f2705%2ftypesetting-column-vector%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
I've added a general solution (with a different syntax) at Typesetting a row vector
– egreg
Sep 30 '12 at 16:37