为了避免编写下面的代码,我需要使用提供的覆盖beamer
。
令人不快的代码
\documentclass[pstricks]{standalone}
\usepackage{pst-node}
\begin{document}
\begin{pspicture}(6,6)
\pnode(0,0){A}
\pnode(6,0){B}
\pnode(6,6){C}
\pnode(0,6){D}
\pnode(1,1){P}
\pnode(5,1){Q}
\pnode(3,5){R}
\pspolygon*[linecolor=red](A)(B)(Q)(P)
\end{pspicture}
\begin{pspicture}(6,6)
\pnode(0,0){A}
\pnode(6,0){B}
\pnode(6,6){C}
\pnode(0,6){D}
\pnode(1,1){P}
\pnode(5,1){Q}
\pnode(3,5){R}
\pspolygon*[linecolor=red](A)(B)(Q)(P)
\pspolygon*[linecolor=green](B)(C)(R)(Q)
\end{pspicture}
\begin{pspicture}(6,6)
\pnode(0,0){A}
\pnode(6,0){B}
\pnode(6,6){C}
\pnode(0,6){D}
\pnode(1,1){P}
\pnode(5,1){Q}
\pnode(3,5){R}
\pspolygon*[linecolor=red](A)(B)(Q)(P)
\pspolygon*[linecolor=green](B)(C)(R)(Q)
\pspolygon*[linecolor=blue](C)(D)(R)}
\end{pspicture}
\begin{pspicture}(6,6)
\pnode(0,0){A}
\pnode(6,0){B}
\pnode(6,6){C}
\pnode(0,6){D}
\pnode(1,1){P}
\pnode(5,1){Q}
\pnode(3,5){R}
\pspolygon*[linecolor=red](A)(B)(Q)(P)
\pspolygon*[linecolor=green](B)(C)(R)(Q)
\pspolygon*[linecolor=blue](C)(D)(R)}
\pspolygon*[linecolor=yellow](D)(A)(P)(R)
\end{pspicture}
\begin{pspicture}(6,6)
\pnode(0,0){A}
\pnode(6,0){B}
\pnode(6,6){C}
\pnode(0,6){D}
\pnode(1,1){P}
\pnode(5,1){Q}
\pnode(3,5){R}
\psclip{\pscircle[linestyle=none,dimen=middle](3,3){3}}
\pspolygon*[linecolor=red](A)(B)(Q)(P)
\pspolygon*[linecolor=green](B)(C)(R)(Q)
\pspolygon*[linecolor=blue](C)(D)(R)}
\pspolygon*[linecolor=yellow](D)(A)(P)(R)
\endpsclip
\end{pspicture}
\end{document}
过去,我使用如下的beamer
文档类和preview
包。不幸的是,代码现在不再可编译。
遗留代码
\documentclass{beamer}
\usepackage{pstricks-add}
\usepackage[active,tightpage]{preview}
\PreviewBorder=0pt
\PreviewEnvironment{pspicture}
\begin{document}
\begin{frame}
\begin{pspicture}(6,6)
\pnode(0,0){A}
\pnode(6,0){B}
\pnode(6,6){C}
\pnode(0,6){D}
\pnode(1,1){P}
\pnode(5,1){Q}
\pnode(3,5){R}
\only<5>{\psclip{\pscircle[linestyle=none,dimen=middle](3,3){3}}}
\only<1->{\pspolygon*[linecolor=red](A)(B)(Q)(P)}
\only<2->{\pspolygon*[linecolor=green](B)(C)(R)(Q)}
\only<3->{\pspolygon*[linecolor=blue](C)(D)(R)}
\only<4->{\pspolygon*[linecolor=yellow](D)(A)(P)(R)}
\only<5>{\endpsclip}
\end{pspicture}
\end{frame}
\end{document}
读了standalone
令人困惑的文档(大多数句子都很难理解)后,我提出了以下想法。但是,我想修剪周围的空格。如何获得紧密的图表?
现代代码
\documentclass[beamer]{standalone}
\usepackage{pstricks-add}
\standaloneenv{pspicture}
\begin{document}
\begin{standaloneframe}
\begin{pspicture}(6,6)
\pnode(0,0){A}
\pnode(6,0){B}
\pnode(6,6){C}
\pnode(0,6){D}
\pnode(1,1){P}
\pnode(5,1){Q}
\pnode(3,5){R}
\only<5>{\psclip{\pscircle[linestyle=none,dimen=middle](3,3){3}}}
\only<1->{\pspolygon*[linecolor=red](A)(B)(Q)(P)}
\only<2->{\pspolygon*[linecolor=green](B)(C)(R)(Q)}
\only<3->{\pspolygon*[linecolor=blue](C)(D)(R)}
\only<4->{\pspolygon*[linecolor=yellow](D)(A)(P)(R)}
\only<5>{\endpsclip}
\end{pspicture}
\end{standaloneframe}
\end{document}
答案1
这是一个解决方法,我不知道它是否有用。我用它geometry
来设置纸张尺寸,然后用\foreach
和几个\ifnum
s 来模拟命令的行为\only
(我想你可以创建一个“仅”宏)。我用 tikz 绘制了这幅图,因为我不熟悉 pstricks,但我认为同样的方法也适用于 pstricks。
\documentclass{article}
\usepackage {geometry}
\usepackage {tikz}
% patper dimensions, style
\geometry {paperwidth=60mm}
\geometry {paperheight=60mm}
\geometry {margin=0mm}
\pagestyle{empty}
\setlength{\parindent}{0pt}
\begin{document}
\foreach\i in {1,...,5}
{%
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (6,0);
\coordinate (C) at (6,6);
\coordinate (D) at (0,6);
\coordinate (P) at (1,1);
\coordinate (Q) at (5,1);
\coordinate (R) at (3,5);
\useasboundingbox (A) rectangle (C);
\ifnum \i = 5
\clip (3,3) circle (3);
\fi
\fill[red] (A) -- (B) -- (Q) -- (P) -- cycle;
\ifnum \i > 1
\fill[green] (B) -- (C) -- (R) -- (Q) -- cycle;
\fi
\ifnum \i > 2
\fill[blue] (C) -- (D) -- (R) -- cycle;
\fi
\ifnum \i > 3
\fill[yellow] (D) -- (A) -- (P) -- (R) -- cycle;
\fi
\end{tikzpicture}
\clearpage
}
\end{document}
编辑:另一个想法,更接近 OP 方法(我认为)。使用beamer
和beamerposter
设置纸张尺寸。我不得不对垂直间距进行一些调整,因为上面有一个令人讨厌的“毫米”空白。还有过满警告。
\documentclass[beamer]{standalone}
\usepackage[size=custom,width=6,height=6]{beamerposter}
\usepackage{tikz}
\setbeamertemplate{navigation symbols}{}
\setbeamersize {text margin left=0cm}
\standaloneenv {tikzpicture}
\begin{document}
\begin{standaloneframe}
\vspace*{-0.35mm}% This number? Trial and error...
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (6,0);
\coordinate (C) at (6,6);
\coordinate (D) at (0,6);
\coordinate (P) at (1,1);
\coordinate (Q) at (5,1);
\coordinate (R) at (3,5);
\useasboundingbox (A) rectangle (C);
\only<5> {\clip (3,3) circle (3);}
\fill[red] (A) -- (B) -- (Q) -- (P) -- cycle;
\only<2->{\fill[green] (B) -- (C) -- (R) -- (Q) -- cycle;}
\only<3->{\fill[blue] (C) -- (D) -- (R) -- cycle;}
\only<4->{\fill[yellow] (D) -- (A) -- (P) -- (R) -- cycle;}
\end{tikzpicture}
\end{standaloneframe}
\end{document}
答案2
最后的手段受到 Juan Castaño 的回答的启发。
\documentclass[pstricks]{standalone}
\usepackage{pst-node}
\begin{document}
\foreach \i in {1,2,3,...,5}{%
\begin{pspicture}(6,6)
\pnode(0,0){A}
\pnode(6,0){B}
\pnode(6,6){C}
\pnode(0,6){D}
\pnode(1,1){P}
\pnode(5,1){Q}
\pnode(3,5){R}
%
\ifnum\i=5\relax
\psclip{\pscircle[linestyle=none,dimen=middle](3,3){3}}
\fi
%
\pspolygon*[linecolor=red](A)(B)(Q)(P)
%
\ifnum\i>1\relax
\pspolygon*[linecolor=green](B)(C)(R)(Q)
\fi
%
\ifnum\i>2\relax
\pspolygon*[linecolor=blue](C)(D)(R)
\fi
%
\ifnum\i>3\relax
\pspolygon*[linecolor=yellow](D)(A)(P)(R)
\fi
%
\ifnum\i=5\relax
\endpsclip
\fi
\end{pspicture}}
\end{document}