如何使用 barr 选项在 XY 中获取双向箭头

如何使用 barr 选项在 XY 中获取双向箭头
\documentclass{article}
\usepackage[cmtip,all,barr]{xy}
\begin{document}

This is a simplified diagram of data flow for LISTSERV. Note that for 
IBM-MAIN the gateway to news is one way; replies to the group do not
propagate to LISTSERV.

\begin{figure}
\[
\bfig
\node browser(0,0)[    \textrm{User web browser}]
\node listserv(0,-500)[    \textrm{LISTSERV}]
\node usenet(1000,-500)[    \textrm{News server}]
\node news(2000,-500)[    \textrm{User news agent}]
\node smtp(0,-1000)[    \textrm{Mail gateway}]
\node imap(-1000,-1500)[    \textrm{IMAP4 server}]
\node user(0,-1500)[    \textrm{User mail agent}]
\node pop(1000,-1500)[    \textrm{POP3 server}]
\arrow |r|/{<-}>/[browser`listserv;HTTP]
%\arrow/{<->}/ |r|[browser`listserv;HTTP]
\arrow |r|[listserv`usenet;NNTP]
\arrow |r|[usenet`news;NNTP]
%\arrow/<->/ |r|[usenet`news;NNTP]
%\arrow/<->/ |r|[listserv`smtp;SMTP]
\arrow |r|[listserv`smtp;SMTP]
%\arrow |r|[smtp`imap]
%\arrow |r|[smtp`pop]
\arrow |a|[imap`user;IMAP4]
\arrow |r|[pop`user;POP3]
%\arrow |r|[user`SMTP]
\efig
\]
\end{figure}
\end{document}

我尝试在 <-> 两边加上括号,但仍然收到错误消息,例如,

Runaway argument?
<->/ |r|[listserv`smtp;SMTP] \arrow |r|[listserv`smtp;SMTP] \arrow |a\ETC.
! File ended while scanning use of \arrowpp.
<inserted text> 
                \par 
<*> E:/temp/LaTeX/listserv.tex

答案1

这不是一个直接的答案,但我觉得你没有使用最佳工具。然而,语法与 Ti 的语法非常相似Z.所以我只是尝试将你的代码翻译成 TiZ 并添加更多 TiZy 版本的图。如果有些箭头没有按照您的想法出现,请原谅我,但解决这个问题很简单。代码的第一部分包含 xy 和 Ti 之间的字典Z,你的原始代码在% 后面。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
%\usepackage[cmtip,all,barr]{xy}
\begin{document}

This is a simplified diagram of data flow for LISTSERV. Note that for 
IBM-MAIN the gateway to news is one way; replies to the group do not
propagate to LISTSERV.

\begin{figure}
\begin{center} %\[
\begin{tikzpicture}[scale=0.35,thick,>=latex] %\bfig
\node (browser) at (0,0) {User web browser};%\node browser(0,0)[    \textrm{User web browser}]
\node (listserv) at (0,-5) {LISTSERV}; %\node listserv(0,-500)[    \textrm{LISTSERV}]
\node (usenet) at (10,-5) {News server}; %\node usenet(1000,-500)[    \textrm{News server}]
\node (news) at (20,-5) {User news agent}; % \node news(2000,-500)[    \textrm{User news agent}]
\node (smtp) at (0,-10) {Mail gateway}; %\node smtp(0,-1000)[    \textrm{Mail gateway}]
\node (imap) at (-12,-15) {IMAP4 server}; % \node imap(-1000,-1500)[    \textrm{IMAP4 server}]
\node (user) at (0,-15) {User mail agent}; % \node user(0,-1500)[    \textrm{User mail agent}]
\node (pop) at (10,-15) {POP3 server}; % \node pop(1000,-1500)[    \textrm{POP3 server}]
\draw[<-] (browser) -- (listserv) node[midway,right]{HTTP}; %\arrow |r|/{<-}>/[browser`listserv;HTTP]
%\arrow/{<->}/ |r|[browser`listserv;HTTP]
\draw[->] (listserv) -- (usenet) node[midway,below]{NNTP}; % \arrow |r|[listserv`usenet;NNTP]
\draw[<->] (usenet) --(news) node[midway,below]{NNTP}; % \arrow |r|[usenet`news;NNTP]
%\arrow/<->/ |r|[usenet`news;NNTP]
%\arrow/<->/ |r|[listserv`smtp;SMTP]
\draw[<->] (listserv)--(smtp) node[midway,right] {SMTP}; % \arrow |r|[listserv`smtp;SMTP]
%\arrow |r|[smtp`imap]
%\arrow |r|[smtp`pop]
\draw[->] (imap) -- (user) node[midway,above]{IMAP4}; % \arrow |a|[imap`user;IMAP4]
\draw[->] (pop) -- (user) node[midway,above]{POP3}; % \arrow |r|[pop`user;POP3]
\draw[->] (user) -- (smtp);%\arrow |r|[user`SMTP]
\end{tikzpicture} %\efig
\end{center}%\]
\caption{A Ti\emph{k}Z version of your figure.}\label{fig:1}
\end{figure}

\begin{figure}
\begin{center} 
\begin{tikzpicture}[node distance=1.6cm,thick,>=latex] 
\node (browser) at (0,0) {User web browser};
\node[below=of browser] (listserv) {LISTSERV}; 
\node[right=of listserv] (usenet) {News server};
\node[right=of usenet] (news) {User news agent}; 
\node[below=of listserv] (smtp) {Mail gateway}; 
\node[below=of smtp] (user)  {User mail agent}; 
\node[left=of user] (imap) {IMAP4 server}; 
\node[right=of user] (pop) {POP3 server}; 
\draw[<-] (browser) -- (listserv) node[midway,right]{HTTP}; 
\draw[->] (listserv) -- (usenet) node[midway,below]{NNTP}; 
\draw[<->] (usenet) --(news) node[midway,below]{NNTP}; 
\draw[<->] (listserv)--(smtp) node[midway,right] {SMTP}; 
\draw[->] (imap) -- (user) node[midway,above]{IMAP4}; 
\draw[->] (pop) -- (user) node[midway,above]{POP3}; 
\draw[->] (user) -- (smtp);
\end{tikzpicture}
\end{center}
\caption{A more Ti\emph{k}Zy version of figure~\ref{fig:1}.}
\end{figure}
\end{document}

在此处输入图片描述

答案2

问题原来是箭头上的语法错误;我的标签位置和形状顺序都错了。这有效:

\documentclass{article}
\usepackage[cmtip,all,barr]{xy}
\begin{document}

This is a simplified diagram of data flow for LISTSERV. Note that for
IBM-MAIN the gateway to news is one way; replies to the group do not
propagate to LISTSERV.

\begin{figure}
\[
\bfig
\node browser(0,0)[\textrm{User web browser}]
\node listserv(0,-500)[\textrm{LISTSERV}]
\node usenet(1000,-500)[\textrm{News server}]
\node news(2000,-500)[\textrm{User news agent}]
\node smtp(0,-1000)[\textrm{Mail gateway}]
\node imap(-1000,-1500)[\textrm{IMAP4 server}]
\node user(0,-1500)[\textrm{User mail agent}]
\node pop(1000,-1500)[\textrm{POP3 server}]
\arrow |r|/{<->}/[browser`listserv;HTTP]
\arrow |r|[listserv`usenet;NNTP]
\arrow |r|[usenet`news;NNTP]
\arrow |r|/<->/[usenet`news;NNTP]
\arrow |r|/<->/[listserv`smtp;SMTP]
\arrow |r|[smtp`imap;]
\arrow |r|[smtp`pop;]
\arrow |a|[imap`user;IMAP4]
\arrow |r|[pop`user;\textrm{POP3}]
\arrow |r|[user`smtp;\textrm{SMTP}]
\efig
\]
\end{figure}
\end{document}

谢谢。

相关内容