Как нейтрализовать кодировки TikZpicture, не удаляя их?

Как нейтрализовать кодировки TikZpicture, не удаляя их?

У меня есть документ, содержащий более сотни tikzpictures, похожих на те, что показаны ниже.

Я хотел бы (если это возможно, легко) создать два разных документа из этого набора кода: (1) как есть; и (2) все, кроме tikzpictures.

Я знаю, что могу скопировать код документа, а затем вручную удалить все 100+ tikzpictures, но надеюсь, что есть лучший способ получить то, что я ищу.

Рассмотрим код:

\documentclass[a5paper,12pt,openany]{book}
\usepackage[paperwidth=5.5in,paperheight=8.25in]{geometry}
\textwidth=4.25in \textheight=7.0in \voffset -7pt

\usepackage[tracking=true]{microtype}  
\usepackage{tikz,lipsum}
\usepackage{mathptmx} 
\definecolor{lightblue}{RGB}{197,213,255}

\begin{document}
\thispagestyle{empty}
\parskip 10pt
\lipsum[13]

\begin{center}
\begin{tikzpicture}[pencildraw/.style={ %
    decorate,
    decoration={random steps,segment length=4pt,amplitude=2.5pt}
    } %
]
\node[preaction={fill=black,opacity=.7,transform canvas={xshift=1mm,yshift=-1mm}},
%pencildraw,
draw,fill=lightblue,text width=0.85\textwidth,inner sep=4mm]
{\begin{minipage}{3.42in} \footnotesize
\selectfont \textbf{\lipsum[13]} \hfill \textbf{\emph{---L. Iipsum}} \end{minipage}};
\end{tikzpicture}
\end{center}

\lipsum[13]

\begin{center}
\begin{tikzpicture}[pencildraw/.style={ %
    decorate,
    decoration={random steps,segment length=4pt,amplitude=2.5pt}
    } %
]
\node[preaction={fill=black,opacity=.7,transform canvas={xshift=1mm,yshift=-1mm}},
%pencildraw,
draw,fill=lightblue,text width=0.85\textwidth,inner sep=4mm]
{\begin{minipage}{3.42in} \footnotesize
\selectfont \textbf{\lipsum[13]} \hfill \textbf{\emph{---L. Iipsum}} \end{minipage}};
\end{tikzpicture}
\end{center}

\lipsum[13]

\begin{center}
\begin{tikzpicture}[pencildraw/.style={ %
    decorate,
    decoration={random steps,segment length=4pt,amplitude=2.5pt}
    } %
]
\node[preaction={fill=black,opacity=.7,transform canvas={xshift=1mm,yshift=-1mm}},
%pencildraw,
draw,fill=lightblue,text width=0.85\textwidth,inner sep=4mm]
{\begin{minipage}{3.42in} \footnotesize
\selectfont \textbf{\lipsum[13]} \hfill \textbf{\emph{---L. Iipsum}} \end{minipage}};
\end{tikzpicture}
\end{center}
\end{document}

который производит:

введите описание изображения здесь

введите описание изображения здесь

ВОПРОС: Существует ли (достаточно простой) способ изменить приведенный выше код так, чтобы LaTeX не выполнял кодировки tikzpicture, а на выходе отображался только текст? (Я компилирую код с помощью pdflatex.)

Спасибо.

решение1

С пакетом environи командой \RenewEnviron:

\documentclass[a5paper,12pt,openany]{book}
\usepackage[paperwidth=5.5in,paperheight=8.25in]{geometry}
\textwidth=4.25in \textheight=7.0in \voffset -7pt

\usepackage[tracking=true]{microtype}  
\usepackage{tikz,lipsum}
\usepackage{mathptmx} 
\definecolor{lightblue}{RGB}{197,213,255}


\usepackage{environ}  %change
\RenewEnviron{tikzpicture}{}{}


\begin{document}
\thispagestyle{empty}
\parskip 10pt
\lipsum[13]

\begin{center}
\begin{tikzpicture}[pencildraw/.style={ %
    decorate,
    decoration={random steps,segment length=4pt,amplitude=2.5pt}
    } %
]
\node[preaction={fill=black,opacity=.7,transform canvas={xshift=1mm,yshift=-1mm}},
%pencildraw,
draw,fill=lightblue,text width=0.85\textwidth,inner sep=4mm]
{\begin{minipage}{3.42in} \footnotesize
\selectfont \textbf{\lipsum[13]} \hfill \textbf{\emph{---L. Iipsum}} \end{minipage}};
\end{tikzpicture}
\end{center}

\lipsum[13]

\begin{center}
\begin{tikzpicture}[pencildraw/.style={ %
    decorate,
    decoration={random steps,segment length=4pt,amplitude=2.5pt}
    } %
]
\node[preaction={fill=black,opacity=.7,transform canvas={xshift=1mm,yshift=-1mm}},
%pencildraw,
draw,fill=lightblue,text width=0.85\textwidth,inner sep=4mm]
{\begin{minipage}{3.42in} \footnotesize
\selectfont \textbf{\lipsum[13]} \hfill \textbf{\emph{---L. Iipsum}} \end{minipage}};
\end{tikzpicture}
\end{center}

\lipsum[13]

\begin{center}
\begin{tikzpicture}[pencildraw/.style={ %
    decorate,
    decoration={random steps,segment length=4pt,amplitude=2.5pt}
    } %
]
\node[preaction={fill=black,opacity=.7,transform canvas={xshift=1mm,yshift=-1mm}},
%pencildraw,
draw,fill=lightblue,text width=0.85\textwidth,inner sep=4mm]
{\begin{minipage}{3.42in} \footnotesize
\selectfont \textbf{\lipsum[13]} \hfill \textbf{\emph{---L. Iipsum}} \end{minipage}};
\end{tikzpicture}
\end{center}
\end{document}

решение2

Я не уверен, может ли это иметь побочные эффекты, я не могу сейчас провести тщательное тестирование, но это работает в MWE: добавить

\RenewDocumentEnvironment{tikzpicture}{o +b}{}{}

как раз перед \begin{document}. По сути, это переопределяет tikzpictureсреду, чтобы ничего не делать.

Вы также можете легко добавить «указатель», например:

\RenewDocumentEnvironment{tikzpicture}{o +b}{\par***Removed tikzpicture***\par}{}или что-то вроде того.

Комментирование этой строки будет включать/выключать компиляцию tikzpicures.

введите описание изображения здесь

Связанный контент