Introducing LaTeX Math Typesetting

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
766 replies · 754K views
how do I set up a case-by-case function definition, i.e.
...{ a if y<1
x = { b if 1&le;y<2
...{ c otherwise

The \cases command doesn't seem to work here.
 
Physics news on Phys.org
[tex]x =\left\{\begin{array}{ccc}a&\mbox{ if }<br /> x<1\\b &\mbox{ if }1\leq y <2 \\c&\mbox{ otherwise}\end{array}\right[/tex]
 
Thanks. Any way to get the "ifs" aligned?

edit: nm; I seem to have gotten it.
 
Last edited:
Yes, I couldn't work it out at first (for info here it is:)
[tex]x =\left\{\begin{array}{lll}a&\mbox{ if }<br /> x<1\\b&\mbox{ if }1\leq y <2 \\c&\mbox{ otherwise }\end{array}\right[/tex]
 
TexAide

This is copied (and edited) from TeXaide (which works exactly like Microsoft Equation Editor)

[tex] x\sum\limits_{i = 0}^\infty {\left( {\begin{array}{*{20}c}<br /> a & b & c \\<br /> {a \times a} & {b \otimes b} & {c\langle c^c \rangle } \\<br /> {a_{\aleph _0 } } & {\wp \left( b \right)} & {\bigcap\limits_c {\Re ^c } } \\<br /> \end{array}} \right)} \frac{\partial }{{\partial x}}\mathop \oplus \limits_x \bigcup + 6\mathop{\left){\vphantom{1{12}}}\right.<br /> \!\!\!\!\overline{\,\,\,\vphantom 1{{12}}}}<br /> \limits^{\displaystyle\hfill\,\,\, 2}<br /> \[/tex]

Can't seem to figure out where that last "]" comes from at the end, but alas - it worked like a charm. Shame that all means nothing!
 
Last edited:
[tex]\textrm{pwnz0rz}= \frac {-1337 \textrm{search engine}\pm \sqrt{(1337 \textrm{search engine})^2-4(1)(\textrm{gmail})}}{2}[/tex]


Hmm, so you can mix words with numbers and pretty print in latex with \textrm.


...dont ask
 
Testing
[tex] \begin{array}{ccccc}1&2\\1&2\\3&2\\2&4\\2&5\\\end{array}[/tex]
[tex] \begin{array}{|c|c|c|c|c|}1&2\\1&2\\3&2\\2&4\\2&5\\\end{array}[/tex]
[tex] \begin{array}{|c|c|c|c|c|}\hline1&2\\\hline\hline1&2\\\hline\hline3&2\\\hline\<br /> \hline2&4\\\hline\hline2&5\\\hline\end{array}[/tex]
 
bored and late

FBox[x_List] := StringJoin@ToString @@@ Flatten[
{
"\begin{array}\n",
"{", "|", Table["
c|", {n, 1, Length[x]}], "}", "\hline", Table[{Table[{ToString[x[[n1,
n2]]], If[n2 ≠ Dimensions[
x][[2]], "&", ""]}, {n2, 1, Dimensions[x][[2]]}], "\\\\", "\hline
"}, {n1, 1, Dimensions[x][[1]]}], "\n \end{array}"
}
]

FBox[{{1, 2}, {1, 2}, {3, 2}, {2, 4}, {2, 5}}]:
[tex] \begin{array}<br /> {|c|c|c|c|c|}\hline1&2\\\hline1&2\\\hline3&2\\\hline2&4\\\hline2&5\\\hline<br /> \end{array}[/tex]
 
F2[x_List] := StringJoin @@ ToString @@@ Flatten[
{
"\begin{array}",
"{", Table["c", {n, 1, Length[x]}], "}",
Table[
{Table[{ToString[x[[n1, n2]]], If[n2
≠ Dimensions[x][[2]], "&", ""]}, {n2, 1, Dimensions[x][[2]]}],
"\\\\"},
{n1, 1, Dimensions[x][[1]]}
],
"\end{array}"
}
]
F2[{{1, 2}, {1, 2}, {3, 2}, {2, 4}, {2, 5}}]:
[tex] \begin{array}{ccccc}1&2\\1&2\\3&2\\2&4\\2&5\\\end{array}[/tex]
 
The above code is for mathematica
 
Why doesn't this work? All I'm trying to do is get 2 left-aligned columns. First I was trying to do it using {array}{cc} formatting similar to the conditional equations up above. That didn't work so I tried this {equation*} layout which is also going haywire. When I was testing a little while ago, I'm pretty sure the same code (but with a smaller amount of content) worked almost correctly; only the first column was right- instead of left-aligned. Now it doesn't work at all.

To accomplish this, the formula will be built up from 3 types of variables, specifically:
[tex]\begin{equation*}\begin{split}\mbox{Variable} \quad &\mbox{Meaning}\\<br /> Q[i,k] \quad &\mbox{At time i, M is in state q_k}\\<br /> H[i,j] \quad &\mbox{At time i, the read-write head}\\<br /> &\mbox{ is scanning tape square j}\\<br /> S[i,j,k] \quad &\mbox{At time i, the contents of}\\<br /> &\mbox{tape square j is symbol s_k}\end{split}\end{equation*}[/tex]


OK this is really crazy; sometimes this works, and sometimes it doesn't, yet it's the same code structure as above:
[tex]\begin{equation*}\begin{split}\mbox{Variable} \quad &\mbox{Meaning}\\<br /> Q[i,k] \quad &\mbox{At time i the read-write head blah blah blah}\\<br /> &\mbox{blah blah blah}\\<br /> H[i,j] \quad &\mbox{At time i}\end{split}\end{equation*}[/tex]
 
Last edited:
Nope. It seems to make no difference whether I format it using {array}{cc} or {array}{11} or {equation*}{split}, \mbox{...} or \text{...]. For example:

To accomplish this, the formula will be built up from 3 types of variables, specifically:
[tex]\begin{array}{11}\mbox{Variable} & \mbox{Meaning}\\<br /> Q[i,k] &\mbox{At time i, M is in state q_k}\\<br /> H[i,j] &\mbox{At time i, the read-write head}\\<br /> &\mbox{ is scanning tape square j}\\<br /> S[i,j,k] &\mbox{At time i, the contents of}\\<br /> &\mbox{tape square j is symbol s_k}\end{array}[/tex]
 
It's not a 1 it's an 'l' and you need one for each row:

edited to add: hmm I can't see anything wrong with this perhaps it's just too big.
 
Last edited:
(I think it's just any series of characters {xxx}, {111}, {iii}, whatever, not some particular one; and isn't it one for each COLUMN, not row?)


Edited to remove my witty(?) remark about the part of your post that you deleted. :wink:
 
Last edited:
No, it's one for each row and 'c' is for centre 'l' is for left I guess.

edited to add: actually you're right but {ll}, {cc} or {rr} is the justifcation.
 
Last edited:
This one works and it's simlair:

[tex]\begin{array}{lr}\mbox{yoink}&\mbox{double-yoink}\\G[i,j]&\mbox{yes}\\H[k,l] &\mbox{no}\\&\mbox{what?}\end{array}[/tex]

I reckon then it must be thta it's just too big as there's a limit to the size of the code.
 
Good find!

That should be helpful.
 
That's it!

[tex]\begin{array}{ll}\mbox{Variable} & \mbox{Meaning}\\<br /> Q[i,k] &\mbox{At time i, M is in state}\, q_k\\<br /> H[i,j] &\mbox{At time i, the read-write head}\\<br /> &\mbox{is scanning tape square j}\\<br /> S[i,j,k] &\mbox{At time i, the contents of}\\<br /> &\mbox{tape square j is symbol}\, s_k\end{array}[/tex]


[tex]\mbox{testing another sub_sc_rip_t}[/tex]

Building on jcsd's find:
the charaters in the brackets after {array} must be
{lll} (that lower-case L's) to left-align
{rrr} to right-align
{"any characters"} to center the text in each column (one char for each column)

Also: apparently subscript like q_k can't be used in \mbox in an array, although it can be used in \mbox when it's not part of an array.

Now I can get back to my "real" post.

Thanks.
:smile: :smile: :smile:
 
Wick Contraction in LaTeX

Wick Contraction-

http://www.fzu.cz/~kolorenc/tex.php

This website has 2 or 3 possible implementations for Wick Contractions in QFT. I have not tried any, but will let you know how they work!
 
Simple question.

Hi everybody,
Does anyone know how do I write a vector quantity, such as an F with an arrow up? I'm not so skilled in Latex.
Thanks
 
OK, let me try once.

[tex] \sum\vec{F}_e_x_t = M\vec{a}_c_m[/tex]
 
Like [tex]cos\theta^{-1}[/tex]?
 
inverse is just ^{-1}, so the (muplicative) inverse of a is a^{-1}, for an inverse function like cos you want \cos^{-1}\theta
 
[tex]\begin{array}P=A(1+\frac{r}{100})^n<br /> \\<br /> \sqrt[n]{\frac{P}{A}}=\frac{r+100}{100}<br /> \\<br /> r=100\sqrt[n]{\frac{P}{A}}-100\end{array}[/tex]
 
Norman said:
Wick Contraction-

http://www.fzu.cz/~kolorenc/tex.php

This website has 2 or 3 possible implementations for Wick Contractions in QFT. I have not tried any, but will let you know how they work!

The simple_wick.tex file works very well. I could not get the other one to work. I also did not have any of the problems the author gives for simple_wick.tex.

Cheers
 
expired post...
 
Last edited: