0

I've defined an environment with \newenvironment, which I am mainly using for tikz diagrams. I have it set to dynamically change the margins, vertically and horizontally center the diagrams, and put each diagram on its own page by calling \clearpage and the end of the environment. That all works well.

My question is how can I output the verbatim contents of the environment automatically at the end of the environment? Ideally after the tikz diagram is finished, I'd like to put the markup that generates that diagram on a new page. So if you were to print it double-sided, you'd have the diagram on one side, and the markup on the other.

I am not sure if this is possible. Here is what I currently have defining the environment. It's working well currently—although please let me know if I am doing something incorrectly.

\documentclass{article}
\usepackage[letterpaper, landscape, margin=0in]{geometry}
\usepackage{tikz}

\newenvironment{myenv}[2]
    {
        \newgeometry{top=#1in, bottom=#1in, left=#2in, right=#2in}
        \vspace*{\fill}
        \begin{center}
    }
    {
        \end{center}
        \vspace*{\fill}
        \clearpage
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        % Something here that will print the content of the environment
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        \restoregeometry
    }

\begin{document}
    \begin{myenv}{1.75}{2}
        \begin{tikzpicture}
            \draw[ultra thick] (-1, 0) -- (1, 0);
        \end{tikzpicture}
    \end{sentencediagram}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.