Re: Newenvironment e afterpage

#79062
Andrea
Partecipante
    Up
    0
    Down
    ::

    egreg9″ post=78252Per favore, modifica il tuo esempio in modo che non faccia alcun riferimento ad altre directory.

    Ciao
    Enrico

    Ecco qui:
    `
    \documentclass[a4paper]{book}

    \usepackage{lmodern}

    \usepackage[T1]{fontenc}
    \usepackage{textcomp} %Gradi e altri simboli
    \usepackage[utf8]{inputenc}

    %In ordine alfabetico
    \usepackage{afterpage} %Svuota coda figura \afterpage{\clearpage}
    \usepackage{environ} %Nuovi ambienti
    \usepackage{lipsum} %Testo casuale
    \usepackage{pdflscape} %Rotazione visualizz pagine
    \usepackage[figuresright]{rotating} %Rotazione figure
    \usepackage{tikz,pgfplots} %Disegno e grafici in LaTeX

    \usetikzlibrary{external}

    %Definisce nuovo comando per input tile tikz
    \makeatletter
    \newcommand{\useexternalfile}[1]{%
    \tikzsetnextfilename{#1-output}%
    \input{\tikzexternal@filenameprefix#1.tex}}
    \makeatother

    %Figure ruotate
    \NewEnviron{mylscape}{%
    \def\tempmylscape{\begin{landscape}\begin{figure}\centering}%
    \expandafter\expandafter\expandafter\afterpage
    \expandafter\expandafter\expandafter %
    {\expandafter\tempmylscape\BODY\end{figure}\end{landscape}}%
    }

    \tikzexternalize %Esternalizzazione

    % INIZIO DOCUMENTO
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \begin{document}

    \tikzsetexternalprefix{}
    \chapter{Primo}
    \lipsum

    \begin{mylscape}
    % \useexternalfile{prova}
    \begin{tikzpicture}[]
    \draw[ultra thick,red] (0,0) rectangle (19,11);
    \end{tikzpicture}
    \caption{Una figura di prova}
    \label{fig:my_fig}
    \end{mylscape}

    \lipsum

    \end{document}
    `

    eliminando il commento da [tt]\useexternalfile{prova}[/tt], si può metter il contenuto di [tt]tikzpicture[/tt] in un file [tt]prova.tex[/tt] nella directory principale.

    Go to top