AASTeX60 icon indicating copy to clipboard operation
AASTeX60 copied to clipboard

AASTeX changes the text aligment in tikz-UML class diagrams

Open isaac-aa opened this issue 8 months ago • 3 comments

Hello,

I'm using tikz-UML for generating class diagrams in a document to be submitted to an AAS journal.

I have encountered a bug which causes the text inside the \umlpackage and \umlclass to be shifted to the right when using aastex631 as the document class. This problem does not happen when setting, for example \documentclass{article}.

This would be the correct behaviour: Image

And this is obtained when using aastex631: Image

To replicate this issue:

  1. Open the example overleaf project for tikz-UML: https://www.overleaf.com/latex/templates/uml-diagrams-with-tikz-uml/ftfzzpmwnjqw
  2. Compile to get the correct, reference class diagram.
  3. Change the documentclass to aastex631.
  4. Recompile and compare the class diagram with the reference.

If not a proper fix to aastex, it would be good enough to have some command to override the conflicting option, if any. Thanks!

isaac-aa avatar Mar 26 '25 11:03 isaac-aa

Hi @isaac-aa! Thanks for this report and the details you provided. I am not sure I am going to be able to give you a work around. We know that AASTeX controls indents to text in a way that causes some incompatibilities with certain packages.

I tried all of the \noindent tricks we have used in the past, including this new to me one -- none prevented the indents inside those umlclass entities. Some of the threads I read suggest that in general tikz competes with many document classes for indent control, and that work arounds are often necessary. I just can't come up with one for this example.

I also note that this incompatibility is true in AASTeX 7 also.

One more fix attempt: I looked through all the manuscripts I have worked on in the past and none has used tikz-uml.sty -- so I can't pass on another author's fix.

Aside: the Overleaf tikz-UML example defaults to TeX Live 2021. This is somewhat important (perhaps to the actual bug too) in that the full unchanged {article}-based Overleaf tikz-UML example will not compile for me without errors in TeX Live 2024 though it does appear to compile w/o errors with TeX Live 2021 on Overleaf. That error is somewhere in "Sequence Diagram".

augustfly avatar Mar 26 '25 14:03 augustfly

Thank you for your swift reply!

I tried some workarounds unsuccessfully, so I decided to delve into aastex632.cls (although I'm in no way an expert LaTeX developer) to look for the conflicting code. I did a simple (yet laborious) manual bisection of the file commenting parts to discover the bug. Finally, I have encountered the lines producing the bug shown above (lines 5583-5593):

\gdef\tabfullpreamble{#2\relax}
{\colcount=0
% important fix, makes it possible to use amsmath and matrices.
\def\two{#2}
\ifx\matrixpreamble\two
\else
\expandafter\countcols\catchpreamble
\global\totalcolumns=\colcount\fi
}

If I simply comment those, I recover the reference solution (or something very close to it, with the text at least centered on the nodes). Funny enough (maybe there is some LaTeX things that I do not understand), if I comment everything inside the curly braces it still shows the buggy behaviour:

\gdef\tabfullpreamble{#2\relax}
{%\colcount=0
% important fix, makes it possible to use amsmath and matrices.
%\def\two{#2}
%\ifx\matrixpreamble\two
%\else
%\expandafter\countcols\catchpreamble
%\global\totalcolumns=\colcount\fi
}

This is the LaTeX source that I'm using to check for the bug:

%
% Compilation of the examples from the TikZ-UML manual, v. 1.0b (2013-03-01)
% http://www.ensta-paristech.fr/~kielbasi/tikzuml/index.php?lang=en
%
%\documentclass[a4paper,12pt]{article}
\documentclass{aastex632}

\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage[french]{babel}
\usepackage{fullpage}

\usepackage{tikz-uml}

\begin{document}

\section{Class Diagram}

\begin{center}
\begin{tikzpicture}
\begin{umlpackage}{p}
\begin{umlpackage}{sp1}
\umlclass[template=T]{A}{
  n : uint \\ t : float
}{}
\umlclass[y=-3]{B}{
  d : double
}{
  \umlvirt{setB(b : B) : void} \\ getB() : B}
\end{umlpackage}
\begin{umlpackage}[x=10,y=-6]{sp2}
\umlinterface{C}{
  n : uint \\ s : string
}{}
\end{umlpackage}
\umlclass[x=2,y=-10]{D}{
  n : uint
  }{}
\end{umlpackage}

\umlassoc[geometry=-|-, arg1=tata, mult1=*, pos1=0.3, arg2=toto, mult2=1, pos2=2.9, align2=left]{C}{B}
\umlunicompo[geometry=-|, arg=titi, mult=*, pos=1.7, stereo=vector]{D}{C}
\umlimport[geometry=|-, anchors=90 and 50, name=import]{sp2}{sp1}
\umlaggreg[arg=tutu, mult=1, pos=0.8, angle1=30, angle2=60, loopsize=2cm]{D}{D}
\umlinherit[geometry=-|]{D}{B}
\umlnote[x=2.5,y=-6, width=3cm]{B}{Je suis une note qui concerne la classe B}
\umlnote[x=7.5,y=-2]{import-2}{Je suis une note qui concerne la relation d'import}
\end{tikzpicture}
\end{center}

\end{document}

In summary, there is something odd with those lines that are causing the bug. To be honest, I do not understand them and I have no idea about how to solve it. It seems that tikz-uml defines tabular environments inside the tikz nodes, maybe that is the relation with those lines (other simple tikz examples work fine). For now, I will just keep a modified cls file for this document.

I hope that this helps to find a permanent solution, or at least help someone else to know that they are not going crazy if they find this bug :) Thanks!

isaac-aa avatar Mar 27 '25 12:03 isaac-aa

Hi @isaac-aa -- thanks for doing such dilligent digging! I think carrying around your modified CLS file for use with this tikz-uml manuscript is the best option. Since we've seen other indent/noindent issues maybe you've found a bug that goes wider than just tikz. We will pass this example on to our latex developers. I'll leave this issue open in the mean time since the bug is also in v7.

augustfly avatar Mar 27 '25 21:03 augustfly