Escrever um texto científico pode ser muito demorado, mas se você trabalha com modelos e precisa de alguns desenhos, você tem um problema em mãos. Estou trabalhando em um artigo que uso cadeias de markov para representar meus modelos, mas não tenho ferramentas de edição delas. Imagine o problema para colocar os modelos no texto usando o LaTeX.
Existem então duas soluções: ou você desenha no paint (ou outro editor gráfico) e exibe no texto como uma figura, ou você usa um desenho programático no LaTeX. Esse post é para falar dessa segunda forma.
Encontrei uma dica interessante de como fazer isso em [1], mas está ainda assim dando trabalho para compreender e usar o exemplo dado para fazer novos modelos.
A primeira coisa é usar o pacote xy, e para isso, use a linha
\usepackage[all]{xy}
Vamos então criar um desenho usando uma malha matricial como guia. Em cada célula da malha, vamos colocar sempre um estado (a bolinha) e uma transição. Para colocar o estado, se usa o seguinte comando:
*+[o][F-]{texto}
Para entender esse comando, o [o] representa que queremos uma forma arredondada, o [F-] faz que ele encolha de acordo com o texto dado dentro das chaves.
Para fazer os arcos, usa-se:
@/^/^{texto exemplo}
Que representa uma seta por cima que tem o “texto exemplo” próximo dela.
Um exemplo simples:
\begin{equation}
\xymatrix{
*+[o][F-]{0} \ar@/^/[r]^{a}& *+[o][F-]{1} \ar@/^/[l]^{b}
}
\label{eq:exampleMarkovChain}
\end{equation}
vai produzir o seguinte resultado:
Veja que o & que está no código é somente para separar as células da malha, assim como quando construímos matrizes.
==========================================================
Write a scientific text can be very slow, but if you work with models and needs some drawings, you have a problem at hand. I am working on an article that use markov chains to represent my models, but have no tools for editing them. Imagine the problem to put the models in the text using LaTeX.
There are two solutions then: either you draw in the paint (or other graphical editor) and displays the text as a picture, or you use a drawing program in LaTeX. This post is to talk about this second way.
I found an interesting hint of how to do this in [1], but is still giving work to understand and use the example given to new models.
The first thing is to use the package xy, and for this, use the line
\usepackage[all](xy)
We will then create a design using a mesh matrix as a guide. In each cell of the loop, we will always place a state (the ball) and a transition. To put the state, you use the following command:
*+[o] [F-] (text)
To understand this command, [o] represents that we want a rounded form, and the last option, [F-] make the form shrink according to the text.
To make the arches, you use:
@/^/^{text example}
That represents an arrow over who has the “text example” close to it.
A simple example:
\begin{equation}
\xymatrix{
*+[o][F-]{0} \ar@/^/[r]^{a}& *+[o][F-]{1} \ar@/^/[l]^{b}
}
\label{eq:exampleMarkovChain}
\end{equation}
it’s gonna produce the following results:
See that & into code? That is the a code needed to separate cells in the mesh. Just as a matrix
[1] http://www.rennes.enst-bretagne.fr/~gbertran/pages/tutorials_latex.html#sujet44
[2] XY Package – http://www.ctan.org/tex-archive/macros/generic/diagrams/xypic/