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

Closed
matteosecli opened this Issue Jun 8, 2016 · 9 comments

Comments

Projects
None yet
3 participants
@matteosecli
Contributor

matteosecli commented Jun 8, 2016

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

\documentclass[tikz]{standalone}
\usepackage{tikz}
\definecolor{myred}{rgb}{0.7,0.1,0.1}
\definecolor{myblue}{rgb}{0,0.447,0.741}    
\begin{document}
    \begin{tikzpicture}
        \tikzset{>=latex}

        %1,0,0
        \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);

        %2,0,0
        \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);

        %2,1,-1
        \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);

        %2,1,0
        \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);

        %2,1,+1
        \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);
    \end{tikzpicture}
\end{document}

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}
                                                  \colorlet{pgf@tempcolor}{....

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

@brucemiller

This comment has been minimized.

Owner

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?

@matteosecli

This comment has been minimized.

Contributor

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! 😄

@brucemiller

This comment has been minimized.

Owner

brucemiller commented Jun 9, 2016

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 :>

@brucemiller brucemiller closed this Jun 9, 2016

@dginev dginev modified the milestones: LaTeXML-0.8.2, LaTeXML-0.8.4 Jun 9, 2016

@dginev dginev added the wontfix label Jun 9, 2016

@matteosecli

This comment has been minimized.

Contributor

matteosecli commented Jun 9, 2016

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.

@brucemiller

This comment has been minimized.

Owner

brucemiller commented Jun 9, 2016

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 from Math labels and custom colors in TikZ to \halign in TikZ and image generation Jun 30, 2016

@brucemiller

This comment has been minimized.

Owner

brucemiller commented Jun 30, 2016

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 :<

@matteosecli

This comment has been minimized.

Contributor

matteosecli commented Jul 1, 2016

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

@matteosecli

This comment has been minimized.

Contributor

matteosecli commented Jul 1, 2016

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!

@brucemiller

This comment has been minimized.

Owner

brucemiller commented Dec 10, 2016

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