Tikz 图片,投影仪,将文本放在一个点上,使其他组件的位置不会改变

Tikz 图片,投影仪,将文本放在一个点上,使其他组件的位置不会改变

我在框架中绘制了一张 tikzpicture,一切正常。但现在我应该向其中添加文本,无论我如何尝试添加文本,其他组件的位置都会发生变化并破坏所有内容(我有空白处并想在其中放置文本)。我找不到任何答案。我该怎么做?

\documentclass{beamer}

\usepackage{tikz} 
\usepackage{smartdiagram}
\usesmartdiagramlibrary{additions}
\tikzset{module/.append style={top color=\col,bottom color=\col}}
\usepackage{adjustbox}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\usetikzlibrary{mindmap,trees}
\usepackage{verbatim}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

        \begin{frame}{Title}
        \begin{adjustbox}{max totalsize={\textwidth}{\textheight},center}
        \begin{tikzpicture}[
              level 1 concept/.append style={text width=3cm,font=\sffamily\LARGE,level distance=6cm,sibling angle=110,
              every child/.style={concept color=orange}},
              level 2 concept/.append style={text width=3cm,font=\sffamily\LARGE,level distance=5cm,sibling angle=90,
              every child/.style={concept color=blue!80!black}}
              ]
          \path[mindmap,concept color=black,text=white]
            node[concept,scale=0.8] {\huge A}
            [clockwise from=-10]
            child[] {
              node[concept] {B}
              [clockwise from=45]
                  child[sibling angle=45] { node[concept] {D}}
                  child[sibling angle=45] { node[concept] {E } }
                  child[sibling angle=45] { node[concept] {F}}
                  child[sibling angle=45] { node[concept] {G} }
            } 
            child[] {
              node[concept] {C}
              [clockwise from=-45]
                child[]{ node[concept]{ H}}
                child[]{ node[concept]{ I}}
            };
        \end{tikzpicture}  
        \end{adjustbox}
        \end{frame}

\end{document}

这是我的代码,其输出如下:

在此处输入图片描述

我想添加文本并获得类似关注的内容,而无需重新定位其他组件。

在此处输入图片描述

答案1

使用remember picture, overlay选项,您可以防止某些部分tikzpiture影响整体大小,以及页面的定位。此外,我会不缩放包含文本的元素,而一个简单的解决方案是使用以下small mindmap样式:

\documentclass{beamer}

\usepackage{adjustbox}
\usepackage{tikz}
\usetikzlibrary{mindmap,overlay-beamer-styles}

\begin{document}

   \begin{frame}{Title}
        \begin{tikzpicture}[
            small mindmap,
              level 1 concept/.append style={
                sibling angle=110,
                every child/.style={concept color=orange}
              },
              level 2 concept/.append style={
                sibling angle=90,
                every child/.style={concept color=blue!80!black}
              }
              ]
          \path[concept color=black,text=white]
            node[concept,scale=0.8] {A}
            [clockwise from=-10]
            child[visible on=<2->] {
              node[concept] {B}
              [clockwise from=45]
                  child[sibling angle=45,visible on=<3->] { node[concept] {D}}
                  child[sibling angle=45,visible on=<3->] { node[concept] {E } }
                  child[sibling angle=45,visible on=<3->] { node[concept] {F}}
                  child[sibling angle=45,visible on=<3->] { node[concept] {G} }
            } 
            child[visible on=<2->] {
              node[concept] {C}
              [clockwise from=-45]
                child[visible on=<4->]{ node[concept]{ H}}
                child[visible on=<4->]{ node[concept]{ I}}
            };
            \begin{scope}[remember picture, overlay]
           \node at (-3,2) {some text};  
           \end{scope}          
        \end{tikzpicture}  
        \end{frame}

\end{document}

在此处输入图片描述

答案2

 \documentclass{beamer}

 \usepackage{tikz} 
 \usepackage{smartdiagram}
 \usesmartdiagramlibrary{additions}
 \tikzset{module/.append style={top color=\col,bottom color=\col}}
 \usepackage{adjustbox}
 \usepackage{tikz}
 \usetikzlibrary{tikzmark}
 \usetikzlibrary{mindmap,trees}
 \usepackage{verbatim}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \newcommand{\nx}{40}%number of divisions on page width
 \newcommand{\ny}{20}%number of divisions on page height
 \usepackage[absolute,overlay
 ,showboxes % comment to make vanish the box
 ]{textpos} %absolute positioning. Use 'showboxes' for viewing the textblock borders box
 \TPGrid{\nx}{\ny}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % A grid for the absolute positioning. Very useful! It's due to Jake with some little change by me.
 \usetikzlibrary{math}
 \newcommand\myGrid{%
    \begin{tikzpicture}[
    overlay,
    remember picture,
    shift={(current page.north west)},
    ]
    \tikzmath{
        \sdx=\nx-1;
        \sdy=\ny-1;
    }
    \draw[very thin, blue!10, xstep=\TPHorizModule, ystep=\TPVertModule]
    (current page.south west) grid (current page.north east);
    \draw[very thin, red!50, xstep=5*\TPHorizModule, ystep=5*\TPVertModule]
    (current page.south west) grid (current page.north east);
    \foreach \x in {1,2,...,\sdx} { \node [xshift=\x*\TPHorizModule,label=below:\tiny\x,inner sep=0pt,outer sep=0pt] at (current page.north west){};}
    \foreach \y in {1,2,...,\sdy} {\node [yshift=-\y*\TPVertModule,label=right:\tiny\y,inner sep=0pt,outer sep=0pt] at (current page.north west) {};}
    \end{tikzpicture}%
 }

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{document}

         \begin{frame}{Title}
 \myGrid %Comment to make vanish the grid
 \begin{textblock}{35}(5,2) %in the bracket the width of the box and in parenthesis the position of the upper left corner
         \begin{adjustbox}{max totalsize={\textwidth}{\textheight},center}
         \begin{tikzpicture}[
               level 1 concept/.append style={text width=3cm,font=\sffamily\LARGE,level distance=6cm,sibling angle=110,
               every child/.style={concept color=orange}},
               level 2 concept/.append style={text width=3cm,font=\sffamily\LARGE,level distance=5cm,sibling angle=90,
               every child/.style={concept color=blue!80!black}}
               ]
           \path[mindmap,concept color=black,text=white]
             node[concept,scale=0.8] {\huge A}
             [clockwise from=-10]
             child[] {
               node[concept] {B}
               [clockwise from=45]
                   child[sibling angle=45] { node[concept] {D}}
                   child[sibling angle=45] { node[concept] {E } }
                   child[sibling angle=45] { node[concept] {F}}
                   child[sibling angle=45] { node[concept] {G} }
             } 
             child[] {
               node[concept] {C}
               [clockwise from=-45]
                 child[]{ node[concept]{ H}}
                 child[]{ node[concept]{ I}}
             };
         \end{tikzpicture}  
         \end{adjustbox}
    \end{textblock}
   \begin{textblock}{7}(5,2)
 this in my text added without relocation of the tikzpicture and any other component
   \end{textblock}
         \end{frame}

 \end{document}

在此处输入图片描述

相关内容