
以下に示すような tikzpicture が 100 枚以上含まれているドキュメントがあります。
私は、そのコード セットから (1) そのままのコードと (2) tikzpictures 以外のすべてのコードという 2 つの異なるドキュメントを (できれば簡単に) 作成したいと考えています。
ドキュメント コードをコピーして、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 のコンパイルが切り替わります。