3

I'm using the following code:

\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
% \usepackage{arydshln} %code doesn't compile anymore with this package

\begin{document}    
 \begin{tikzpicture}
 \node at (0,0){$\begin{aligned}
                  & A \to B\\
                  & A \\\hline  
                  & B
                 \end{aligned}$};
 \end{tikzpicture}  
\end{document}

to produce this (the actual formula is a bit longer but I don't think that does matter):

enter image description here

Problem is that in other parts of the document I need to use the \hdashline macro from the arydshln package and it seems that the package conflicts with the \hline macro when placed inside the aligned environment.

I tried replacing \hline with \cline and \hhline but both produce something like this:

enter image description here

with too much whitespace around the horizontal line.

Is there a way to have an horizontal line like\hline in an aligned environment while the arydshln is loaded? It would be ok also to change the environment to something else, assuming it works inside a TikZ node.

  • 1
    What about $\begin{array}{@{}l@{}} instead of aligned? – egreg Apr 28 '13 at 16:23
  • @egreg works! thanks. Is it also possible to move up the horizontal line a bit? As it is it almost touches the "B." – Nico Vecchio Apr 28 '13 at 16:38
  • \extrarowheight of the array package might help. – egreg Apr 28 '13 at 16:39
  • @egreg, sorry, nevermind, it works just fine as it is, the line I was seeing was another one I was drawing with TikZ for test purpose :) – Nico Vecchio Apr 28 '13 at 16:42
2

The aligned environment is not based on tabular or array, so \hline and similar commands are not guaranteed to work; this is definitely true, it seems, for the extended lines provided by arydshln.

Use array:

\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{arydshln}

\begin{document}
\begin{tikzpicture}
\node at (0,0)
  {$\begin{array}{@{}l@{}}
    A \to B\\
    A \\
    \hdashline
    B
    \end{array}$
  };
\end{tikzpicture}
\end{document}

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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