pgf-tikz / pgf-umlcd

Automatically exported from code.google.com/p/pgf-umlcd
Other
8 stars 3 forks source link

LuaTeX support #2

Open hmenke opened 3 years ago

hmenke commented 3 years ago

Brief outline of the bug

pgf-umlcd doesn't work with LuaTeX because of

! LaTeX Error: Command \attribute already defined.
               Or name \end... illegal, see p.192 of the manual.

Minimal working example (MWE)

\documentclass{article}
\usepackage{pgf-umlcd}
\begin{document}
\end{document}
atticus-sullivan commented 2 years ago

As can be seen at luatex-doc(Page 24, section 2.3.2), the macro \attribute is already in use by LuaTeX (for some new ~counter implementation stuff). I think only Line 227 in the .sty would need to be changed for resolving. As this is the macro for the interface to the outside, the question is how to name it (classAttribute isn't that accurate I think).

Most important is that by simply renaming the macro there wouldn't be any backwards compatibility. I'd suggest to add the ifluatex/iftex package or some equivalent so that the new macro can be used in all versions, but prevent the redefinition of attribute in a lua(la)tex environment.

[Because of the open question regarding the naming and since I didn't dug into the doc code yet (might be subject to change as well), I didn't do a pull request. In addition I'm not sure if this is the right way of contributing to this project (or if there has to be some mailinglist action or something else)]

TeXhackse commented 2 years ago

@hmenke Is there any plan to fix this one?

I guess the only stable way to resolve this permanently would be changing the user Syntax (probably backwards compatible for pdfLaTeX). I could do such changes if that would help. Or are there any other ideas?

complanar commented 2 years ago

Seems, this is not as complicated as it seems. Quick dirty fix:

Changing Line 227 in the .sty to \newcommand{\umlAttribute}[1]{ and then redefining \attribute only inside of the classAndInterfaceCommon environment by adding \let\attribute\umlAttribute (around Line 199) does the trick.

I'm only a LaTeX user and no package author, so this is maybe dirty code and does not meet the standards, but probably someone knows a better solution. In the meantime I kind of “fixed“ my copy of the package this way. As of now I didn't experience any side effects.

TeXhackse commented 2 years ago

I currently use the hook management to workaround it, so \attribute is overwritten within the internal environments of this package. But it's not a good solution to overwrite it. There might be a usecase which might make use of the luatex attribute within the environment. So it's not a good solution to overwrite it. Not even locally.

complanar commented 2 years ago

You’re right, that‘s why I called it a quick dirty fix. I didn’t want to recommend this solution for the package maintainer, but for me it is better than not to be able to use the package at all. Just wanted to share this workaround with others.