Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I tried to draw the following diagram in LaTeX

enter image description here

I reference the method from here:

I can successfully compile the code from above link, but when I attempted to draw more lines between A and B by modifying the number in the:

\draw[shorten <=-1cm,shorten >=-1cm,-latex] (m-4-2.south west)--(m-4-2.south east);
\draw[shorten <=-1cm,shorten >=-1cm,-latex] (m-7-2.south east)--(m-7-2.south west);

I always got the error message said:

Package pgf Error: No shape named m-5-2 is known.

Any solution for this problem? Thanks.

share|improve this question
    
Welcome to TeX.SX! The syntax m-4-2 means: node in row 4 and column 2; if your matrix has no nodes in that cell, you get that error. –  Claudio Fiandrino May 18 at 6:51
    
That error can also occur if you use \node inside a matrix of nodes (see e.g. tex.stackexchange.com/questions/163319/…). Is this the case? –  Torbjørn T. May 18 at 7:12
    
Thanks for the hint! –  Yang Xia May 19 at 0:57

1 Answer 1

up vote 3 down vote accepted

Use a simple array environment:

\documentclass{article}
\usepackage{mathtools}

\def\XLR#1{\xleftrightarrow[\rule{2cm}{0pt}]{#1}}% \rule defines the width
\def\XR#1{\xrightarrow[\rule{2cm}{0pt}]{#1}}
\def\XL#1{\xleftarrow[\rule{2cm}{0pt}]{#1}}
\begin{document}

\[
\begin{array}{@{} c c c @{}}
A  &  & B \\
   & \XLR{\text{KE}} \\
\text{obtain }k,T^A_{\text{KE}} &  & \text{obtain }k,T^B_{\text{KE}} \\
K:= \text{PRF}(k,\text{"KE"})   &  & K:= \text{PRF}(k,\text{"KE"})   \\
K_\text{mac}:= \text{PRF}(k,\text{"MAC"})   &  & K_\text{mac}:= \text{PRF}(k,\text{"MAC"}) \\
   & \XR{r_A} \\
   & \XL{r_B} \\
\text{[...]}
 \end{array}
\]
\end{document}

enter image description here

share|improve this answer
    
Thanks a lot. I figured out my own way to do it :) –  Yang Xia May 19 at 0:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.