如何缩放外部文件中的 tikzpicture 以用于投影仪幻灯片?

如何缩放外部文件中的 tikzpicture 以用于投影仪幻灯片?

我在一个单独的文档中有一个 tikz 图表。我使用该standalone包将其包含到我的演示文稿中。但是,我遇到了几个问题:

  • 设置包含的图片大小
  • 缩放图片,使其与可见框架区域完全匹配
  • 将图片放置在文件内的任意位置

为了具体起见,这是我的主要文件

\documentclass{beamer}
\usepackage{standalone}
\usepackage{tikz}

\usecolortheme{wolverine}
\setbeamertemplate{headline}{inflines theme}
\setbeamertemplate{footline}{infolines theme}

\setbeamertemplate{headline}{%
 \hbox{%
   \begin{beamercolorbox}[wd=.25\paperwidth]{section in head/foot}%
   \end{beamercolorbox}%
   \begin{beamercolorbox}[wd=.75\paperwidth]{section in head/foot}%
   \end{beamercolorbox}%
 }%
}%

\defbeamertemplate*{footline}{infolines theme}{\relax
  \leavevmode%
  \hbox{\relax
  \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
  \end{beamercolorbox}}%
  \vskip0pt%
}

\begin{document}
  \begin{frame}\frametitle{Frame Title}
       \include{mindmap}
   \end{frame}
\end{document}

虽然包含的 tikzpicture 位于名为 的文件中mindmap.tex,但

\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage{tikz}
\begin{document}
\usetikzlibrary{mindmap,shadows}
\begin{tikzpicture}[mindmap]
  \begin{scope}
 [
 every node/.style={concept,circular drop shadow,execute at begin node=\hskip0pt},
 text=white,
 root concept/.append style={
   concept color=black, fill=black, line width=1ex, text=white, font=\large\scshape
 },
 grow cyclic,
level 1/.append style={level distance=4.5cm,sibling angle=51.5,font=\itshape},
level 2/.append style={level distance=3cm,sibling angle=45,font=\bf\scriptsize}
]
  \node at (0,100) [fill=white, line width=1ex, text=black,font=\large\scshape] {Introduction to Programming Languages} [clockwise from=0] 
     child [concept color=gray] { node {Administration} [clockwise from=75]
        child {node {Office Hours} }
        child {node {Course Material} }
        child {node {Exams} }
        child {node {Assignments} }
     }  
     child [concept color=purple, sibling angle=33] { node {Hello, World!} } 
     child [concept color=green!50!black, sibling angle=33] { node {Syntactical Elements} 
         [clockwise from=-10]   
     child { node {Identifiers} 
           [clockwise from=0]
           child { node {Autarkic} 
             child { node {Pre-Declared Identifiers} }
           }
           child [sibling angle=60]{ node {Library Based} }
         }
     child { node {Literals} 
           [clockwise from=-60]
           child { node {String Literals} 
              [clockwise from=0]
              child { node{Escaping} } 
           }
         }
     child { node {Keywords} }
     child { node {Comments} }
     child { node {Blocks} }
     } 
     child [concept color=red!30,text=black, sibling angle=46] { node {Specification} [scale=2,clockwise from = -90]
       child {node {Semantics}
       [clockwise from = -45]
     child { node {Recursively Defined Sets} }
     child [sibling angle=60] { node {Language Legalese} }
     child [sibling angle=60] { node {Formal Semantics} }
       } 
       child[sibling angle=90] {node {Syntax} 
       [clockwise from = 210]
    child {node {RegExp}}
    child [sibling angle=45] {node {BNF}}
    child [sibling angle=45] {node {EBNF}}
      }  
    }
    child [concept color=yellow!40, text=black,sibling angle=45] { node {Motivation} }
    child [concept color=teal,sibling angle=53] { node {Paradigms} [clockwise from=45]
    [clockwise from = -150]      
      child { node {Imperative} }
      child [sibling angle=60] { node {Functional} }
      child [sibling angle=60]{ node {Logical} }
      child [sibling angle=60] { node {OO}}
    }
    child [concept color=orange] { node {History} } 
 ;
 \end{scope}%
\end{tikzpicture}%
\end{document}

我得到的输出非常烦人:

包含 tikzpicture 的演示文稿

顺便说一句,我读过这个问题,为 Beamer 幻灯片缩放 tikzpicture,而且它似乎并没有阐明这个问题。

答案1

你不应该\usetikzlibrary{mindmap,shadows}在序言之外使用。要包含具有指定宽度的思维导图,只需使用

\includestandalone[width=.75\linewidth]{mindmap}

subpreambles如果包选项设置为 ,则可以使用所包含文件的前言true

如果您只绘制图像,您可能希望用 替换\documentclass{article}\documentclass{standalone}

请尝试创建 MWE。主文档和大树中的所有格式都没有真正的理由

您的代码可能如下所示:

主文本

\documentclass{beamer}
\usepackage[subpreambles=true]{standalone}
\usepackage{tikz}


\usepackage{lipsum}

\usecolortheme{wolverine}
\setbeamertemplate{headline}{inflines theme}
\setbeamertemplate{footline}{infolines theme}

\setbeamertemplate{headline}{%
 \hbox{%
   \begin{beamercolorbox}[wd=.25\paperwidth]{section in head/foot}%
   \end{beamercolorbox}%
   \begin{beamercolorbox}[wd=.75\paperwidth]{section in head/foot}%
   \end{beamercolorbox}%
 }%
}%

\defbeamertemplate*{footline}{infolines theme}{\relax
  \leavevmode%
  \hbox{\relax
  \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
  \end{beamercolorbox}}%
  \vskip0pt%
}

\begin{document}
  \begin{frame}\frametitle{Frame Title}
       \centering
       \includestandalone[width=.75\linewidth]{mindmap}

   \end{frame}
\end{document}

思维导图.tex:

\documentclass{article}

\usepackage{tikz}

\usetikzlibrary{mindmap,shadows}
\begin{document}
\begin{tikzpicture}[mindmap]
  \begin{scope}
 [
 every node/.style={concept,circular drop shadow,execute at begin node=\hskip0pt},
 text=white,
 root concept/.append style={
   concept color=black, fill=black, line width=1ex, text=white, font=\large\scshape
 },
 grow cyclic,
level 1/.append style={level distance=4.5cm,sibling angle=51.5,font=\itshape},
level 2/.append style={level distance=3cm,sibling angle=45,font=\bf\scriptsize}
]
  \node at (0,100) [fill=white, line width=1ex, text=black,font=\large\scshape] {Introduction to Programming Languages} [clockwise from=0] 
     child [concept color=gray] { node {Administration} [clockwise from=75]
        child {node {Office Hours} }
        child {node {Course Material} }
        child {node {Exams} }
        child {node {Assignments} }
     }  
     child [concept color=purple, sibling angle=33] { node {Hello, World!} } 
     child [concept color=green!50!black, sibling angle=33] { node {Syntactical Elements} 
         [clockwise from=-10]   
     child { node {Identifiers} 
           [clockwise from=0]
           child { node {Autarkic} 
             child { node {Pre-Declared Identifiers} }
           }
           child [sibling angle=60]{ node {Library Based} }
         }
     child { node {Literals} 
           [clockwise from=-60]
           child { node {String Literals} 
              [clockwise from=0]
              child { node{Escaping} } 
           }
         }
     child { node {Keywords} }
     child { node {Comments} }
     child { node {Blocks} }
     } 
     child [concept color=red!30,text=black, sibling angle=46] { node {Specification} [scale=2,clockwise from = -90]
       child {node {Semantics}
       [clockwise from = -45]
     child { node {Recursively Defined Sets} }
     child [sibling angle=60] { node {Language Legalese} }
     child [sibling angle=60] { node {Formal Semantics} }
       } 
       child[sibling angle=90] {node {Syntax} 
       [clockwise from = 210]
    child {node {RegExp}}
    child [sibling angle=45] {node {BNF}}
    child [sibling angle=45] {node {EBNF}}
      }  
    }
    child [concept color=yellow!40, text=black,sibling angle=45] { node {Motivation} }
    child [concept color=teal,sibling angle=53] { node {Paradigms} [clockwise from=45]
    [clockwise from = -150]      
      child { node {Imperative} }
      child [sibling angle=60] { node {Functional} }
      child [sibling angle=60]{ node {Logical} }
      child [sibling angle=60] { node {OO}}
    }
    child [concept color=orange] { node {History} } 
 ;
 \end{scope}%
\end{tikzpicture}%
\end{document}

结果

相关内容