4

I am trying to create a maze and its solution using the labyrinth package inside a standalone document class akin to a tikz. However, when I try to compile, I run into the following error (MWE given below)

! LaTeX Error: Not allowed in LR mode. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.5 ...abyrinth}[unit=12pt, thickness=1pt]{19}{20} 

Here is the MWE

\documentclass{standalone} % document type and language \usepackage{labyrinth} \begin{document} \begin{labyrinth}[unit=12pt, thickness=1pt]{19}{20} \putsymbol(8,\minus1){\Large$\Uparrow$} \putsymbol(10,20){\Large$\Uparrow$} \h *9+---*7+ \v +*5-+--+--+---+--+ \h -*4+--+-+-*4+--+ \v +*4-++-++---+--++-+ \h *4+--+--+++--++--+ \v +---++-++---+++--+-+ \h -++--+---++*4-+++ \v +--++-+-++-+-+++---+ \h ++--+-+++--++---+++ \v +--+-+*4-++-*4+--+ \h -+++-*4+-+*6-+ \v +---++---++-++-+-+-+ \h +++---++--++-++---+ \v +--++---++--+--+++-+ \h -+--+++--++-++---+ \v +-++---++--+--+-++-+ \h +---++--++-++-++--+ \v +-+++-+++--+-++--+-+ \h -+*7-++*4-+++ \v ++-*6+-+-+-+-+--+ \h --+*8-*4+--++ \v ++--*8+-+-++--+ \h -+++*{12}-++ \v +-+--+-+-++-+-++--++ \h +--*7+-+++-++ \v +-+---+---+---+-+-++ \h -++-+--++-+++-++-+ \v ++-+-+---++-+-+--+-+ \h ---+-+++*5-+-++-+ \v +++-++--++-++-++-+-+ \h --+---+--++-+*4-+ \v ++-+-+-++--++-+-+-++ \h -+-+++--++*4-+++ \v +---+-++--*5+-*4+ \h -++*4-++ \v ++-*4+--+-+--*6+ \h *6-++-*5+ \v *4+-++*8-+-+++ \h ---+++-+-+-*6+ \v +-+*4-+--+*8-+ \h *7+---*9+ \autosolution[font=\color{Orange}](8,0)(10,19){u} \labyrinthsolution[ font=\color{MidnightBlue}\footnotesize, up=\kern2pt$\uparrow$, left=$\leftarrow$, down=\kern2pt$\downarrow$, right=$\rightarrow$, hcorr=0.1\unitlength, vcorr=0.3\unitlength, ](7,1){% ldlllluulddluuuuuuuruluuurulurrdd% dldrruuurrrddddluuuldddlldrrrdr% } \end{labyrinth} \end{document} 

What is going wrong here? I did not find any documentation on the incompatibility between the two packages. And what is the fix here?

    2 Answers 2

    4

    You need varwidth and to add some border (gauging visually, I'm afraid).

    \documentclass[varwidth,border={1 16 1 11}]{standalone} \usepackage[dvipsnames]{xcolor} \usepackage{labyrinth} \begin{document} \begin{labyrinth}[unit=12pt, thickness=1pt]{19}{20} \putsymbol(8,\minus1){\Large$\Uparrow$} \putsymbol(10,20){\Large$\Uparrow$} \h *9+---*7+ \v +*5-+--+--+---+--+ \h -*4+--+-+-*4+--+ \v +*4-++-++---+--++-+ \h *4+--+--+++--++--+ \v +---++-++---+++--+-+ \h -++--+---++*4-+++ \v +--++-+-++-+-+++---+ \h ++--+-+++--++---+++ \v +--+-+*4-++-*4+--+ \h -+++-*4+-+*6-+ \v +---++---++-++-+-+-+ \h +++---++--++-++---+ \v +--++---++--+--+++-+ \h -+--+++--++-++---+ \v +-++---++--+--+-++-+ \h +---++--++-++-++--+ \v +-+++-+++--+-++--+-+ \h -+*7-++*4-+++ \v ++-*6+-+-+-+-+--+ \h --+*8-*4+--++ \v ++--*8+-+-++--+ \h -+++*{12}-++ \v +-+--+-+-++-+-++--++ \h +--*7+-+++-++ \v +-+---+---+---+-+-++ \h -++-+--++-+++-++-+ \v ++-+-+---++-+-+--+-+ \h ---+-+++*5-+-++-+ \v +++-++--++-++-++-+-+ \h --+---+--++-+*4-+ \v ++-+-+-++--++-+-+-++ \h -+-+++--++*4-+++ \v +---+-++--*5+-*4+ \h -++*4-++ \v ++-*4+--+-+--*6+ \h *6-++-*5+ \v *4+-++*8-+-+++ \h ---+++-+-+-*6+ \v +-+*4-+--+*8-+ \h *7+---*9+ \autosolution[font=\color{Orange}](8,0)(10,19){u} \labyrinthsolution[ font=\color{MidnightBlue}\footnotesize, up=\kern2pt$\uparrow$, left=$\leftarrow$, down=\kern2pt$\downarrow$, right=$\rightarrow$, hcorr=0.1\unitlength, vcorr=0.3\unitlength, ](7,1){% ldlllluulddluuuuuuuruluuurulurrdd% dldrruuurrrddddluuuldddlldrrrdr% } \end{labyrinth} \end{document} 

    output

    0
      3

      by default standalone typesets in horizontal mode to measure the width, but you can use varwidth option so it tries parboxes of different widths. Also you had used undefined colors.

      enter image description here

      \documentclass[varwidth]{standalone} % document type and language \usepackage[dvipsnames]{xcolor} \usepackage{labyrinth} \begin{document} \begin{labyrinth}[unit=12pt, thickness=1pt]{19}{20} \putsymbol(8,\minus1){\Large$\Uparrow$} \putsymbol(10,20){\Large$\Uparrow$} \h *9+---*7+ \v +*5-+--+--+---+--+ \h -*4+--+-+-*4+--+ \v +*4-++-++---+--++-+ \h *4+--+--+++--++--+ \v +---++-++---+++--+-+ \h -++--+---++*4-+++ \v +--++-+-++-+-+++---+ \h ++--+-+++--++---+++ \v +--+-+*4-++-*4+--+ \h -+++-*4+-+*6-+ \v +---++---++-++-+-+-+ \h +++---++--++-++---+ \v +--++---++--+--+++-+ \h -+--+++--++-++---+ \v +-++---++--+--+-++-+ \h +---++--++-++-++--+ \v +-+++-+++--+-++--+-+ \h -+*7-++*4-+++ \v ++-*6+-+-+-+-+--+ \h --+*8-*4+--++ \v ++--*8+-+-++--+ \h -+++*{12}-++ \v +-+--+-+-++-+-++--++ \h +--*7+-+++-++ \v +-+---+---+---+-+-++ \h -++-+--++-+++-++-+ \v ++-+-+---++-+-+--+-+ \h ---+-+++*5-+-++-+ \v +++-++--++-++-++-+-+ \h --+---+--++-+*4-+ \v ++-+-+-++--++-+-+-++ \h -+-+++--++*4-+++ \v +---+-++--*5+-*4+ \h -++*4-++ \v ++-*4+--+-+--*6+ \h *6-++-*5+ \v *4+-++*8-+-+++ \h ---+++-+-+-*6+ \v +-+*4-+--+*8-+ \h *7+---*9+ \autosolution[font=\color{Orange}](8,0)(10,19){u} \labyrinthsolution[ font=\color{MidnightBlue}\footnotesize, up=\kern2pt$\uparrow$, left=$\leftarrow$, down=\kern2pt$\downarrow$, right=$\rightarrow$, hcorr=0.1\unitlength, vcorr=0.3\unitlength, ](7,1){% ldlllluulddluuuuuuuruluuurulurrdd% dldrruuurrrddddluuuldddlldrrrdr% } \end{labyrinth} \end{document} 
      0

        You must log in to answer this question.

        Start asking to get answers

        Find the answer to your question by asking.

        Ask question

        Explore related questions

        See similar questions with these tags.