Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\halign in TikZ and image generation #760

matteosecli opened this issue Jun 8, 2016 · 9 comments

\halign in TikZ and image generation #760

matteosecli opened this issue Jun 8, 2016 · 9 comments


Copy link

matteosecli commented Jun 8, 2016

Hi all, I've encountered a couple of problems in processing a simple TikZ picture. My MWE is


        \draw [ultra thick] (-1,-3) -- (1,-3) node[midway,below,align=center] {\null \\ \scriptsize $|1,0,0\rangle$};
        \draw [very thick, myblue, ->] (-0.5,-3.5) -- (-0.5,-2.5);
        \draw [very thick, myblue, ->] (0.5,-2.5) -- (0.5,-3.5);

        \draw [ultra thick] (-1,0.5) -- (1,0.5) node[midway,below,align=center] {\null \\ \scriptsize $|2,0,0\rangle$};
        \draw [very thick, myblue, ->] (-0.5,0) -- (-0.5,1);
        \draw [very thick, myblue, ->] (0.5,1) -- (0.5,0);

        \draw [ultra thick] (-4,2) -- (-2,2) node[midway,below,align=center] {\null \\ \scriptsize $|2,1,-1\rangle$};
        \draw [very thick, myblue, ->] (-3.5,1.5) -- (-3.5,2.5);
        \draw [very thick, myblue, ->] (-2.5,2.5) -- (-2.5,1.5);

        \draw [ultra thick] (-1,2) -- (1,2) node[midway,below,align=center] {\null \\ \scriptsize $|2,1,0\rangle$};
        \draw [very thick, myblue, ->] (-0.5,1.5) -- (-0.5,2.5);
        \draw [very thick, myblue, ->] (0.5,2.5) -- (0.5,1.5);

        \draw [ultra thick] (4,2) -- (2,2) node[midway,below,align=center] {\null \\ \scriptsize $|2,1,1\rangle$};
        \draw [very thick, myblue, ->] (2.5,1.5) -- (2.5,2.5);
        \draw [very thick, myblue, ->] (3.5,2.5) -- (3.5,1.5);

The output, as processed by PDFLaTeX, is MWE.pdf. I've avoided here to use the braket package (which I normally use for this picture, anyway) just to focus on the problem. When I convert using latexml MWE.tex --destination=MWE.xml, it keeps spitting out errors of the kind

Error:malformed:ltx:Math <ltx:Math> isn't allowed here
    at /home/cloud/Dropbox/UNI/MANY_BODY_THEORY/Exercises/ALL_EXERCISES_LATEXML/BUG/MWE.tex; line 10 col 111
    Currently in ...<svg:g _font="Font[nullfont,medium,upright,1..." stroke-width="1.6pt" _box="LaTeXML::Core::Whatsit=HASH(0x...">...<svg:g _font="Font[nullfont,medium,upright,1..." transform="matrix(1 0 0 1 -26.98 -173.64)" _box="LaTeXML::Core::Whatsit=HASH(0x...">...<svg:g _box="LaTeXML::Core::Alignment=HASH(..." _font="Font[serif,medium,upright,10,b..." class="ltx_tikzmatrix">...<svg:g _box="LaTeXML::Core::Alignment=HASH(..." _font="Font[serif,medium,upright,10,b..." class="ltx_tikzmatrix_row">...<svg:g _box="LaTeXML::Core::Alignment=HASH(..." _font="Font[serif,medium,upright,10,b..." class="ltx_tikzmatrix_col ltx_align_center"/>
    In Core::Document[@0x71888d0] at /home/cloud/Dropbox/UNI/MANY_BODY_THEORY/Exercises/ALL_EXERCISES_LATEXML/BUG/MWE.tex; line 10 col 111
     <= Core::Definition::Constructor[$] <= Whatsit[\@@BEGININLINEMATH,Core::List... <= Core::Document[@0x71888d0] <= ...

which seems to show that LaTeXML doesn't like my math labels in the picture. Then, by doing latexmlpost --svg --format=html5 --verbose --destination=MWE.html MWE.xml I almost get the correct output, but without the labels '|x,y,z>'. And here my first question: is it possible to have an SVG output to an external file, i.e. generate some 'picture1.svg' by direct LaTeX compilation and then include the image file in the html? I've tried with multiple options, but I haven't figured out a way to do that.

So, I've tried to generate a PNG file instead (because I know that LaTeXML uses LaTeX to generate PNG images) by using latexmlpost --pictureimages --verbose --destination=MWE.html MWE.xml but here LaTeX completely fails the compilation, and it gives me errors of the kind

! Package xcolor Error: Undefined color `myblue'.

See the xcolor package documentation for explanation.
Type  H <return>  for immediate help.

l.60 ...pgfsys@setlinewidth{1.2pt}{}\color{myblue}

The DVI output in the log folder is completely empty, apart from a small square in the upper left corner.

I'm on Ubuntu 14.04, with TeXLive 2013 (TeX 3.1415926-2.5-1.40.14), and the latest Git version of LaTeXML (Oh, btw, I've set up a PPA that builds everyday the master branch of this repo and produces Debian packages for different versions of Ubuntu. If you want to do some tests of the packages or leave me a feedback about them, this is the PPA.)

Thanks in advance for your help! 😄

@dginev dginev added this to the LaTeXML-0.8.4 milestone Jun 8, 2016
Copy link

brucemiller commented Jun 9, 2016

It's not the math, I think, and actually there is support for the braket package. I think the problem is that LaTeXML (well, me actually) hasn't figured out how to deal with \halign occuring within pgf They're tricky enough on a good day, without trying to guess what pgf is actually trying to arrange. Currently, there are "HALIGN IN PGF!" messages printed out while processing as a reminder that someday that has to be figured out.

If I simply remove the \null \\ bits from your labels, the processing runs fine, although the labels are, of course, not quite where you wanted them. I'm not tikz-expert enough to suggest alternatives, but maybe there's another way to get the positioning w/o invoking the \halign?

Copy link
Contributor Author

matteosecli commented Jun 9, 2016

My fault, the \null \\ bits are a reflection of my laziness when it comes to TikZ. 😅
Changing the lines into a more elegant \draw [ultra thick] (-1,-3) -- (1,-3) node[midway,below,align=center,yshift=-0.6\baselineskip] {\scriptsize $\Ket{1,0,0}$}; does the trick, indeed! 😄

Copy link

Cool! I would say that I'd like to keep the issue open as a reminder that I eventually have to fix haligns, but actually I don't want to be reminded! So, maybe we close and wait for a real problem with alignments to come up :>

Copy link
Contributor Author

The halign problem is "solved" for me, too. However, there is still the issue with the custom color stuff; I tried again with the new code, but keeps giving the same error about the undefined color.

Copy link

Oh, you mean to generate the png from the picture! Ugh, LaTeXML doesn't realize that it needs to copy that color (somehow) to the latex... hmm...

@brucemiller brucemiller reopened this Jun 9, 2016
@dginev dginev modified the milestones: LaTeXML-0.8.3, LaTeXML-0.8.2 Jun 23, 2016
@brucemiller brucemiller changed the title Math labels and custom colors in TikZ \halign in TikZ and image generation Jun 30, 2016
Copy link

I've made some progress with image generation; at least user colors don't cause a problem. And also the re-generated TeX has an appropriate size associated. So it generates some kind of image; just not the right one :<

Copy link
Contributor Author

Great, I'll test it out asap! 😄
(PS: I've just switched to a smarter naming scheme of the daily DEBs of LaTeXML that I produce, since I noticed that the recent removal of 439 revisions broke up the previous one! 😆)

@dginev dginev removed the wontfix label Jul 1, 2016
Copy link
Contributor Author

Just tested the latest version, and now it works correctly when I use latexmlpost --pictureimages --verbose --destination=MWE.html MWE.xml (with the adjustment used here).
Thank you! 👍 😄

PS: 👍 also for the documentation revamp, I've just noticed it!

@teepeemm teepeemm mentioned this issue Aug 3, 2016
Copy link

Oh! guess this one is done. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

3 participants