TeX - LaTeX Asked by Houssam Sabri on February 17, 2021
I want to construct a figure with Tikz similar to this one:
I was looking for example but couldn’t find any I tried to make it but it was a mess.
so: How can I get the spins on the dots? and how to put them in a table while still being a tikz figure?
Thank you for your valuable help
With a tabular environment and a tikz newcommand
you can do the following:
documentclass[border=2mm]{standalone}
usepackage{ifthen}
usepackage{tikz}
newcommand{level}[3]% up (1)/down (0), up (1)/down (0), labels (y/n)
{
begin{tikzpicture}
useasboundingbox (0,-0.25) rectangle (2,1.25);
draw[blue,thick,-latex] (0,1-#1) -- (0,#1);
draw[red ,thick,-latex] (2,1-#2) -- (2,#2);
draw[dashed] (0,0.5) -- (2,0.5);
fill (0,0.5) circle (2pt);
fill (2,0.5) circle (2pt);
ifthenelse
{equal{#3}{y}}
{%
node at (0,0) [below] {$S_i$};
node at (2,0) [below] {$S_j$};
node at (1,0.5) [above] {$J_{ij}$};
}
{}
end{tikzpicture}
}
renewcommand{arraystretch}{2}
begin{document}
begin{tabular}{|c|c|}cline{1-2}
bfseries State 1 & bfseries State 2 hline
level{1}{1}{y} & level{1}{0}{n} hline
bfseries State 3 & bfseries State 4 hline
level{0}{1}{n} & level{0}{0}{n} hline
multicolumn{2}{|c|}{$displaystyle J_{ij}=frac{E_1+E_4-E_3-E_2}{4|S_iS_j|}$}[2mm]hline
end{tabular}
end{document}
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/XGc5e.png
Correct answer by Juan Castaño on February 17, 2021
Maybe you can do this without tikz in a usual table using constructions as this one:
documentclass{article}
defqeq{mathrel{%
mathchoice{QEQ}{QEQ}{scriptsizeQEQ}{tinyQEQ}%
}}
defQEQ{{%
setbox0hbox{textbullet}%
rlap{hbox to wd0{hss$uparrow$hss}}box0
}}
begin{document}
$qeq$ textbullet , textbullet , textbullet
end{document}
Answered by ubuntuuser on February 17, 2021
documentclass{article}
usepackage{array}
usepackage{makecell}
usepackage{amsmath}
usepackage{tikz}
usetikzlibrary{positioning, arrows.meta}
tikzset{node distance = 1cm, baseline={(0,0)}}
newcommand{spinup}[1][]{
draw[-Triangle , draw=#1, very thick] (0,0ex) -- (0ex,2em) node (up) {};
draw[fill=black, draw=#1, draw=black] (0ex,1em) circle (0.5ex);
} % inspired by https://tex.stackexchange.com/a/314648/134144
newcommand{spindown}[1][]{
draw[Triangle-, draw=#1, very thick] (0,0ex) -- (0ex,2em)node (down) {};
draw[fill=black, draw=#1, draw=black] (0ex,1em) circle (0.5ex);
}
newcommand{energylevel}{draw [dotted] (0,0.9em) -- (1cm, 0.9em);}
setcellgapes{3pt}
begin{document}
makegapedcells
begin{tabular}{|wc{2cm}|wc{2cm}|}
hline
State 1 & State 2
hline
begin{tikzpicture}
energylevel;
node at (0.5cm,2em) {$J_{ij}$};
spinup[blue];
node[below of = up]{$S_i$};
spinup[red, right of= up]
node[below of = up]{$S_j$};
end{tikzpicture}
&
begin{tikzpicture}
spinup[blue];
spindown[red, right of= up];
energylevel
end{tikzpicture}
hline
State 3 & State 4
hline
begin{tikzpicture}
energylevel;
spindown[blue];
spinup[red, right of= down]
end{tikzpicture}
&
begin{tikzpicture}
spindown[blue];
spindown[red, right of= down];
energylevel
end{tikzpicture}
hline
multicolumn{2}{|c|}{(displaystyle J_{ij} = frac{E_1 + E_4 - E_3 - E_2}{4 | S_i S_j |} )}
hline
end{tabular}
end{document}
Answered by leandriis on February 17, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP