2

Here is my MWE:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage[all]{xy}
\makeatletter
\newcommand{\test}{\xymatrix@M=-.3pt@=10pt}
\newcommand{\testt}[2][1]{\ar@[|(1)]@#1{-}[#2]}
\makeatother


\begin{document}
\begin{align*}
&f=\test{
& \bullet \testt{dl} \testt{dr} \\
\bullet & & \circ }
&g=\test{
 & & \bullet \testt{dl}\testt{d}\testt{dr}\\
& \bullet & \bullet \testt{d} & \bullet \testt{d}\\
& & \circ & \circ }
\end{align*}
\end{document}

Please help!!!!!

related to this Is that a bug between `xymatrix`, the `input` command and .sty file? but solution not working

CarLaTeX
  • 62,716

1 Answers1

4

Just comment out \makeatletter (and \makeatother) since otherwise the @ (and ordinary characters that follow them) become part of the macros. (This is sort of what the answer you link to is trying to say.)

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage[all]{xy}
%\makeatletter
\newcommand{\test}{\xymatrix@M=-.3pt@=10pt}
\newcommand{\testt}[2][1]{\ar@[|(1)]@#1{-}[#2]}
%\makeatother


\begin{document}
\begin{align*}
&f=\test{
& \bullet \testt{dl} \testt{dr} \\
\bullet & & \circ }
&g=\test{
 & & \bullet \testt{dl}\testt{d}\testt{dr}\\
& \bullet & \bullet \testt{d} & \bullet \testt{d}\\
& & \circ & \circ }
\end{align*}
\end{document}

enter image description here

  • Is there any possibility to work with \makeatletter and \makeatoher ?? – New to latex Feb 14 '20 at 06:26
  • @Newtolatex Why do you want to do that? Is there a reason why you wish to keep \makeatletter "switched on"? –  Feb 14 '20 at 06:28
  • Am using own cls and sty files there are more \makeatletter and \makeatother – New to latex Feb 14 '20 at 06:35
  • @Newtolatex In cls and sty files, \makeatletter is "switched on" automatically. Then you need to switch it of for the purpose of these command definitions. That is, inside a package you need \makeatother \newcommand{\test}{\xymatrix@M=-.3pt@=10pt} \newcommand{\testt}[2][1]{\ar@[|(1)]@#1{-}[#2]} \makeatletter. –  Feb 14 '20 at 06:39
  • Great working fine!!!! – New to latex Feb 14 '20 at 07:06