1

I know it's a little localized, but bear with me as I need to know how to do this. Here's an image of what I have to do: enter image description here

So as you can see I have to draw these lines. I know how to add text on them and how to rotate them (\turn), but how can I position the second line text correctly?

UPDATE: I also need to have double arrows like this: enter image description here

  • I guess I could also use tikz-cd, couldn't I? – user2563892 Sep 29 '14 at 17:55
  • 2
    It would be helpful if you composed a fully compilable MWE including \documentclass and the appropriate packages that sets up the problem. i.e., what is in the image provided leaving out the non-horizontal arrows? – Peter Grill Sep 29 '14 at 18:18
  • Well I tried the first example I read in the manual, but it used square braces which gave an error. So IMHO the manual is outdated. I thought I could use shift left, but is there some automagical way of doing that? – user2563892 Sep 30 '14 at 13:51

2 Answers2

3

With the mhchem and pst-node packages,it's easy. Note tha the pdf option lets you compile with pdflatex provided you compile with the -shell-escape (for TeX Live or MacTeX) or--enable-write18` (for MiKTeX) switch.

\documentclass[pdf]{report}
\usepackage{pst-node}
\usepackage{mhchem}

\begin{document}

\[ \psset{arrows = ->, nodesep = 3pt, labelsep = 3pt, colsep = 1.2cm, rowsep = 1.2cm, npos = 0.45, arrowinset=0.2}
\begin{psmatrix}
 \ce{Cr} & \ce{Cr2O3} & \ce{CrCl3} &\ce{Cr(OH)3} & \ce{Cr2O3}\\
 & &\ce{KCrO2} & \ce{Cr(NO3)3}\\[0.5cm]
\ce{Al2(SO4)3} & \ce{Al(OH)3}
 \ncline{1,1}{1,2}\naput{1} \ncline{1,2}{1,3} \ncline{1,3}{1,4}\naput{3}\ncline{1,4}{1,5}\naput{4}
 \ncline{1,2}{2,3}\naput[npos=0.5]{5}\ncline{1,4}{2,3}\ncline{1,4}{2,4}\naput{7}
 \ncline{2,3}{2,4}\naput{6}
%
\psset{tpos = 0.52}
\ncline[offset=0.667ex]{3,1}{3,2}\taput{2}\ncline[offset=0.667ex]{3,2}{3,1}\tbput{7}
\end{psmatrix} \]

\end{document} 

enter image description here

Bernard
  • 271,350
  • Your answer is ok, but the other one with tikz-cd seems a bit easier – user2563892 Sep 30 '14 at 12:53
  • @user2563892: It's a different philosophy: in psmatrix, one defines first the nodes, then the links between nodes. With tikz-cd, nodes and links are mixed. I also use tikz-cd from time to time, but I find pstricks generally easier to customise, because its syntax is closer to LaTeX's. – Bernard Sep 30 '14 at 13:29
  • OK, but I actually need more help and here's the customizability that might come in handy. I'll update question in a moment and you'll see. – user2563892 Sep 30 '14 at 13:36
  • @user2563892: See my updated answer. – Bernard Sep 30 '14 at 14:03
  • Yes, thanks. Now I'm stuck, how do I vote both answers? :) – user2563892 Sep 30 '14 at 14:08
  • 2
    @user2563892: That's not a problem: I'm here to help, not to compete. – Bernard Sep 30 '14 at 14:12
2

Since you seem to be waiting for a tikz-cd-solution (Thanks to Bernard for typing all the formulae from your drawing):

% arara: pdflatex

\documentclass{article}
\usepackage{tikz-cd}
\usepackage{mhchem}

\begin{document}    
    \begin{tikzcd}[row sep=0.6cm]
        \ce{Cr} \arrow{r}{1} & \ce{Cr2O3} \arrow{r} \arrow{dr}[swap]{5} & \ce{CrCl3} \arrow{r}{3} & \ce{Cr(OH)3} \arrow{dl} \arrow{r}{4} \arrow{d}{7} & \ce{Cr2O3}\\
        & &\ce{KCrO2} \arrow{r}{6} & \ce{Cr(NO3)3} &
    \end{tikzcd}    
\end{document}

enter image description here

If you want to rotate the number 5 to the same angle of the arrow, you may write \arrow{dr}[swap,sloped]{5}.


Edit:

For your second picture:

\documentclass{article}
\usepackage{tikz-cd}
\usepackage{mhchem}

\begin{document} 
    \[   
    \begin{tikzcd}
        \ce{Al2(SO4)3} \arrow[shift left]{r}{2} & \ce{Al(OH)3} \arrow[shift left]{l}{7} 
    \end{tikzcd} 
    \]   
\end{document}

enter image description here

LaRiFaRi
  • 43,807
  • Im getting undefined control sequence – user2563892 Sep 30 '14 at 13:03
  • I changed \ce to \ch, sorry – user2563892 Sep 30 '14 at 13:05
  • Missing number, treated as zero. – user2563892 Sep 30 '14 at 14:09
  • \ch{Al2O3} \arrow{r}{1} & \ch{Al2(SO4)3} \arrow[yshift=0.667ex]{r}{2} & \ch{Al(OH)3} \arrow[shift left=0.667ex]{l}{7} – user2563892 Sep 30 '14 at 14:32
  • @user2563892 Please updated your TeX-distribution. I am not getting any error with the above code. I do not understand your last comment. Why hard code it, when it does look good as it is and why not use shift left twice. And you are using \ch and not \ce so I have to suppose that you haven't compiled the MWE I posted. – LaRiFaRi Sep 30 '14 at 15:09
  • So the tex distribution is the problem, ok. The second code is what works for me. How can I update it? I run an apt-get upgrade every week so I dont think it could be that outdated. And also, I did compile your MWE. – user2563892 Sep 30 '14 at 15:33