缩放 tikzpicture 以适合投影仪框架

缩放 tikzpicture 以适合投影仪框架

我如何垂直缩放图形以适应框架?

\begin{frame}{P\textsuperscript{H}metry studies}
\begin{figure}[scale=0.5\textheight]
\begin{tikzpicture}
\node [block] at (0,6) (GERD){GERD};
\node [block] at (-3,4) (Esophagitis){Reflux esophagitis};
\node [block] at (0,4) (NERD){NERD};
\node [block] at (3,4) (Barret){Barret's esophagitis};
\node [block] at (0,2) (Ph){Ph testing};
\node [block] at (-3,0) (positive) {Ph +ve NERD};
\node [block] at (3,0) (Negative){Functional heart burn};
\node[] at (3,-2)(Symptoms) {\footnotesize {Symptoms associated with P\textsuperscript{H} changes?}};
\node [block] at (5, -4)(hypersensitive) {hypersensitive esophagus};
\node[block] at (1,-4)(unassociated){Acid unassociated heart burn};
\begin{scope}[cyan!40!black]
\draw[->] (GERD) -- (Esophagitis);
\draw[->] (GERD) -- (NERD);
\draw[->] (GERD) -- (Barret);
\draw[->] (NERD)--(Ph);
\draw[->](Ph)--(positive);
\draw[->](Ph)--(Negative);
\draw[->](Negative)--(Symptoms);
\draw[->](Symptoms)--(unassociated);
\draw[->](Symptoms)--(hypersensitive);
\end{scope} 
\end{tikzpicture}
\end{figure}
\end{frame}

答案1

一个选项是使用比例因子tikzpicture

\documentclass{beamer}
\usepackage{tikz}

\tikzset{
  invisible/.style={opacity=0},
  visible on/.style={alt=#1{}{invisible}},
  alt/.code args={<#1>#2#3}{%
    \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
  },
}
\tikzset{
block/.style = {
  rectangle,
  thick,
  text width=6em,
  align=center,
  rounded corners,
  draw=cyan!40!black,
  fill=cyan!20,
  inner ysep=10pt
  }
}

\begin{document}

\begin{frame}{P\textsuperscript{H}metry studies}
\begin{figure}
\begin{tikzpicture}[scale=0.7,transform shape]
\node [block] at (0,6) (GERD){GERD};
\node [block] at (-3,4) (Esophagitis){Reflux esophagitis};
\node [block] at (0,4) (NERD){NERD};
\node [block] at (3,4) (Barret){Barret's esophagitis};
\node [block] at (0,2) (Ph){Ph testing};
\node [block] at (-3,0) (positive) {Ph +ve NERD};
\node [block] at (3,0) (Negative){Functional heart burn};
\node[] at (3,-2)(Symptoms) {\footnotesize {Symptoms associated with P\textsuperscript{H} changes?}};
\node [block] at (5, -4)(hypersensitive) {hypersensitive esophagus};
\node[block] at (1,-4)(unassociated){Acid unassociated heart burn};
\begin{scope}[cyan!40!black]
\draw[->] (GERD) -- (Esophagitis);
\draw[->] (GERD) -- (NERD);
\draw[->] (GERD) -- (Barret);
\draw[->] (NERD)--(Ph);
\draw[->](Ph)--(positive);
\draw[->](Ph)--(Negative);
\draw[->](Negative)--(Symptoms);
\draw[->](Symptoms)--(unassociated);
\draw[->](Symptoms)--(hypersensitive);
\end{scope} 
\end{tikzpicture}
\end{figure}
\end{frame}

\end{document}

enter image description here

另一个选择是使用\resizebox

\documentclass{beamer}
\usepackage{tikz}

\tikzset{
  invisible/.style={opacity=0},
  visible on/.style={alt=#1{}{invisible}},
  alt/.code args={<#1>#2#3}{%
    \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
  },
}
\tikzset{
block/.style = {
  rectangle,
  thick,
  text width=6em,
  align=center,
  rounded corners,
  draw=cyan!40!black,
  fill=cyan!20,
  inner ysep=10pt
  }
}

\begin{document}

\begin{frame}{P\textsuperscript{H}metry studies}
\begin{figure}
\resizebox{!}{.8\textheight}{%
\begin{tikzpicture}
\node [block] at (0,6) (GERD){GERD};
\node [block] at (-3,4) (Esophagitis){Reflux esophagitis};
\node [block] at (0,4) (NERD){NERD};
\node [block] at (3,4) (Barret){Barret's esophagitis};
\node [block] at (0,2) (Ph){Ph testing};
\node [block] at (-3,0) (positive) {Ph +ve NERD};
\node [block] at (3,0) (Negative){Functional heart burn};
\node[] at (3,-2)(Symptoms) {\footnotesize {Symptoms associated with P\textsuperscript{H} changes?}};
\node [block] at (5, -4)(hypersensitive) {hypersensitive esophagus};
\node[block] at (1,-4)(unassociated){Acid unassociated heart burn};
\begin{scope}[cyan!40!black]
\draw[->] (GERD) -- (Esophagitis);
\draw[->] (GERD) -- (NERD);
\draw[->] (GERD) -- (Barret);
\draw[->] (NERD)--(Ph);
\draw[->](Ph)--(positive);
\draw[->](Ph)--(Negative);
\draw[->](Negative)--(Symptoms);
\draw[->](Symptoms)--(unassociated);
\draw[->](Symptoms)--(hypersensitive);
\end{scope} 
\end{tikzpicture}%
}
\end{figure}
\end{frame}

\end{document}

enter image description here

相关内容