Graphics, Figures & Tables ⇒ Markov Latex
Markov Latex
Hello people
how to do this Markov diagram in Latex?
Thankss
how to do this Markov diagram in Latex?
Thankss
- Attachments
-
- markov latex.png (30.08 KiB) Viewed 13684 times
NEW: TikZ book now 40% off at Amazon.com for a short time.

- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
Markov Latex
Like this?
Stefan
Code: Select all
Code, edit and compile here:
\documentclass[tikz, border=10pt]{standalone}\usetikzlibrary{calc, automata, chains, arrows.meta}\begin{document}\begin{tikzpicture}[start chain = going right,-Triangle, every loop/.append style = {-Triangle}]\foreach \i in {0,...,4}\node[state, on chain] (\i) {\i};\foreach \i in {0,...,3} {\draw let \n1 = { int(\i+1) } in(\i) edge[bend left] (\n1)(\n1) edge[bend left] (\i);}\foreach \i in {1,...,3}\draw (\i) edge[loop below] (\i);\draw (0) edge[loop left] (0);\draw (4) edge[loop right] (4);\end{tikzpicture}\end{document}
LaTeX.org admin
Re: Markov Latex
yesssssss is perfect!!!!!
But one thing more, I would to writte text or number above the arrows.
I do not know how to do it.
Can you help me?
Thanks
But one thing more, I would to writte text or number above the arrows.
I do not know how to do it.
Can you help me?
Thanks
- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
Re: Markov Latex
Sure, this is easy with nodes on the edges.
I just need to go to sleep now, I will write again tomorrow.
Stefan
I just need to go to sleep now, I will write again tomorrow.
Stefan
LaTeX.org admin
- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
Markov Latex
I just have few time. Don't worry, I like TikZ questions.
It's actually simple: the new
A user variable can also be added for text or numbers in a for loop:
Complete example - note that I added the quotes library at the beginning:
Stefan
It's actually simple: the new
quotes
library, which comes with TikZ 3.0 or later, brings an easy syntax instead of adding nodes:Code: Select all
\draw (0) edge[loop left, "left"] (0);\draw (4) edge[loop right, "right"] (4);
Code: Select all
\foreach \i/\txt in {1/here,2/there,3/here too}\draw (\i) edge[loop below, "\txt"] (\i);
Code: Select all
Code, edit and compile here:
\documentclass[tikz, border=10pt]{standalone}\usetikzlibrary{calc, automata, chains, arrows.meta, quotes}\begin{document}\begin{tikzpicture}[start chain = going right,-Triangle, every loop/.append style = {-Triangle}]\foreach \i in {0,...,4}\node[state, on chain] (\i) {\i};\foreach \i in {0,...,3} {\draw let \n1 = { int(\i+1) } in(\i) edge[bend left] (\n1)(\n1) edge[bend left] (\i);}\foreach \i/\txt in {1/here,2/there,3/here too}\draw (\i) edge[loop below, "\txt"] (\i);\draw (0) edge[loop left, "left"] (0);\draw (4) edge[loop right, "right"] (4);\end{tikzpicture}\end{document}
LaTeX.org admin
Markov Latex
Sorry Stefan, I have seen the code during all day and I have a problem that I don`t know solve
If you run/execute this code, you will se the strange problem
thanks

If you run/execute this code, you will se the strange problem
Code: Select all
Code, edit and compile here:
\documentclass[12pt,a4paper,tikz,border=10pt]{article}\usepackage[spanish]{babel}\usepackage[utf8]{inputenc}\usepackage{amsmath}\usepackage{amsfonts}\usepackage{amssymb}\usepackage{listings}\usepackage{fancybox}\usepackage{fancyvrb}\usepackage{enumerate}\usepackage{pstricks}\usepackage{graphicx}\usepackage{enumitem}\usepackage{parskip}\usepackage{tikz}\usetikzlibrary{calc, automata, chains, arrows.meta, quotes}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\usepackage[left=3cm,right=2cm,top=1cm,bottom=2cm]{geometry}\title{Cadenes de Markov}\date{}%%%%%%%%%%%%%%%%%%%%% COLORES %%%%%%%%%%%%%%%%%%%%%%%\usepackage{color}\definecolor{gray97}{gray}{.97}\definecolor{gray75}{gray}{.75}\definecolor{gray45}{gray}{.45}\usepackage{mdframed}\usepackage{subfig}\usepackage{epsfig}\usepackage{enumitem}\usepackage{listings}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\begin{document}\maketitle
- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
Markov Latex
It's caused by the shorthand " which is a spanish babel command. You could disable it by
Either globally in the preamble, if you don't use it, or locally in the TikZ picture, at the beginning.
Stefan
Code: Select all
\shorthandoff{"}
Stefan
LaTeX.org admin
Markov Latex
oh yes!! thanks Stefan !!!
Sorry but I need the last one thing, I don´t know to writte above translation.
I tried this but it does not run
but not compilation :S
I need this: (photo)
thanks
Sorry but I need the last one thing, I don´t know to writte above translation.
I tried this but it does not run
Code: Select all
Code, edit and compile here:
\draw (\i) edge[bend left,"\txt"] (\n1)\draw (0) edge[bend left,"a"] (1)
I need this: (photo)
thanks
- Attachments
-
- markov-writte.png (17.55 KiB) Viewed 13602 times