tikz tcolorbox add tag
topnush
I am trying to put a box in the top right of a beamer slide. I don't want it to move anything else on the page. However the tikzpicture below with the word `hello` does move the rest of the slide down. 

```
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\setbeamersize{text margin left=10mm,text margin right=5mm} 
\setbeamertemplate{frametitle}[default][center]
\usepackage[many]{tcolorbox}

\usepackage{listings}

\tcbuselibrary{skins}
\tcbset{
%	arc=0pt,
%	outer arc=0pt,
	colback=white,
}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
	shapes,
	tikzmark, shapes.geometric}
\usetikzmarklibrary{listings}


\newtcolorbox{mytheorem}[2][]{%
	text width=7.5cm, text height=1.5cm, enhanced,colback=white,colframe=framecolour, coltitle=comcolor,
	sharp corners,boxrule=0.8mm,
	attach boxed title to top left={yshift=-0.3\baselineskip-0.4pt,xshift=2mm},
	boxed title style={tile,size=minimal,left=0.5mm,right=0.5mm,
		colback=white,before upper=\strut},
	title=#2,#1
}


\definecolor{comcolor}{RGB}{10,161,119}
\definecolor{framecolour}{HTML}{009980}


\begin{document}

\begin{frame}[t]{Summary}
\begin{tikzpicture}[remember picture,overlay, scale=0.9, transform shape]
\node[draw, overlay, very thick, rounded corners, fill=green!30, anchor=north west, xshift=12cm, yshift=-0.5cm] at (current page.north west) {hello};
\end{tikzpicture}
\begin{mytheorem}[colframe=red, text width=10cm]{}

\end{mytheorem}

\pause
\begin{enumerate}[<+->] 
\setlength\itemsep{5pt plus 1fill}
\item one
\item two
\item three
\item four
\item five
\item six
\end{enumerate}

\end{frame}

\end{document}
```
Top Answer
samcarter
The situation is a bit tricky because even if it won't take up any space, the `tikzpicture` will still have to start a line and `tcolorbox` you use afterwards will go in a fresh line.

### Approach 1:

You can works around this by placing your `tikzpicture` into the theorem box:

```
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\setbeamersize{text margin left=10mm,text margin right=5mm} 
\setbeamertemplate{frametitle}[default][center]
\usepackage[many]{tcolorbox}

\usepackage{listings}

\tcbuselibrary{skins}
\tcbset{
%	arc=0pt,
%	outer arc=0pt,
	colback=white,
}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
	shapes,
	tikzmark, shapes.geometric}
\usetikzmarklibrary{listings}


\newtcolorbox{mytheorem}[2][]{%
	text width=7.5cm, text height=1.5cm, enhanced,colback=white,colframe=framecolour, coltitle=comcolor,
	sharp corners,boxrule=0.8mm,
	attach boxed title to top left={yshift=-0.3\baselineskip-0.4pt,xshift=2mm},
	boxed title style={tile,size=minimal,left=0.5mm,right=0.5mm,
		colback=white,before upper=\strut},
	title=#2,#1
}


\definecolor{comcolor}{RGB}{10,161,119}
\definecolor{framecolour}{HTML}{009980}


\begin{document}

\begin{frame}[t]
\frametitle{Summary}
\begin{mytheorem}[colframe=red, text width=10cm]{}
\begin{tikzpicture}[remember picture,overlay, scale=0.9, transform shape]
\node[draw, overlay, very thick, rounded corners, fill=green!30, anchor=north west, xshift=12cm, yshift=-0.5cm] at (current page.north west) {hello};
\end{tikzpicture}test

\end{mytheorem}

\pause
\begin{enumerate}[<+->] 
\setlength\itemsep{5pt plus 1fill}
\item one
\item two
\item three
\item four
\item five
\item six
\end{enumerate}

\end{frame}

\end{document}
```

### Approach 2:

you could also try to hide the space from the additional line:

```
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\setbeamersize{text margin left=10mm,text margin right=5mm} 
\setbeamertemplate{frametitle}[default][center]
\usepackage[many]{tcolorbox}

\usepackage{listings}

\tcbuselibrary{skins}
\tcbset{
%	arc=0pt,
%	outer arc=0pt,
	colback=white,
}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
	shapes,
	tikzmark, shapes.geometric}
\usetikzmarklibrary{listings}


\newtcolorbox{mytheorem}[2][]{%
	text width=7.5cm, text height=1.5cm, enhanced,colback=white,colframe=framecolour, coltitle=comcolor,
	sharp corners,boxrule=0.8mm,
	attach boxed title to top left={yshift=-0.3\baselineskip-0.4pt,xshift=2mm},
	boxed title style={tile,size=minimal,left=0.5mm,right=0.5mm,
		colback=white,before upper=\strut},
	title=#2,#1
}


\definecolor{comcolor}{RGB}{10,161,119}
\definecolor{framecolour}{HTML}{009980}


\begin{document}

\begin{frame}[t]
\frametitle{Summary}
{\nointerlineskip%
\begin{tikzpicture}[remember picture,overlay, scale=0.9, transform shape]
\node[draw, overlay, very thick, rounded corners, fill=green!30, anchor=north west, xshift=12cm, yshift=-0.5cm] at (current page.north west) {hello};
\end{tikzpicture}%
}%
\begin{mytheorem}[colframe=red, text width=10cm]{}

\end{mytheorem}

\pause
\begin{enumerate}[<+->] 
\setlength\itemsep{5pt plus 1fill}
\item one
\item two
\item three
\item four
\item five
\item six
\end{enumerate}

\end{frame}

\end{document}
```

### Approach 3 (preferred):

Personally, I would not use the crude `\pause` command and use normal overlays instead. This has the advantage, that you can place the `tikzpicture` at the end of the top aligned frame, so nothing bad should happen even if it might add one more line


```
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\setbeamersize{text margin left=10mm,text margin right=5mm} 
\setbeamertemplate{frametitle}[default][center]
\usepackage[many]{tcolorbox}

\usepackage{listings}

\tcbuselibrary{skins}
\tcbset{
%	arc=0pt,
%	outer arc=0pt,
	colback=white,
}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
	shapes,
	tikzmark, shapes.geometric}
\usetikzmarklibrary{listings}


\newtcolorbox{mytheorem}[2][]{%
	text width=7.5cm, text height=1.5cm, enhanced,colback=white,colframe=framecolour, coltitle=comcolor,
	sharp corners,boxrule=0.8mm,
	attach boxed title to top left={yshift=-0.3\baselineskip-0.4pt,xshift=2mm},
	boxed title style={tile,size=minimal,left=0.5mm,right=0.5mm,
		colback=white,before upper=\strut},
	title=#2,#1
}


\definecolor{comcolor}{RGB}{10,161,119}
\definecolor{framecolour}{HTML}{009980}


\begin{document}

\begin{frame}[t]
\frametitle{Summary}
\begin{mytheorem}[colframe=red, text width=10cm]{}
test
\end{mytheorem}

\begin{uncoverenv}<+->
\begin{enumerate}[<+->] 
\setlength\itemsep{5pt plus 1fill}
\item one
\item two
\item three
\item four
\item five
\item six
\end{enumerate}
\end{uncoverenv}
\begin{tikzpicture}[remember picture,overlay, scale=0.9, transform shape]
\node[draw, overlay, very thick, rounded corners, fill=green!30, anchor=north west, xshift=12cm, yshift=-0.5cm] at (current page.north west) {hello};
\end{tikzpicture}%
\end{frame}

\end{document}
```
Answer #2
marmot
I never really knew what the `nobeforeafter` key in `tcolorbox` is really good for, but this very situation seems to be one where it appears to be useful.
```
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\setbeamersize{text margin left=10mm,text margin right=5mm} 
\setbeamertemplate{frametitle}[default][center]
\usepackage[many]{tcolorbox}

\usepackage{listings}

\tcbuselibrary{skins}
\tcbset{
%	arc=0pt,
%	outer arc=0pt,
	colback=white,
}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
	shapes,
	tikzmark, shapes.geometric}
\usetikzmarklibrary{listings}


\newtcolorbox{mytheorem}[2][]{%
	text width=7.5cm, text height=1.5cm, enhanced,colback=white,colframe=framecolour, coltitle=comcolor,
	sharp corners,boxrule=0.8mm,
	attach boxed title to top left={yshift=-0.3\baselineskip-0.4pt,xshift=2mm},
	boxed title style={tile,size=minimal,left=0.5mm,right=0.5mm,
		colback=white,before upper=\strut},
	title=#2,#1
}


\definecolor{comcolor}{RGB}{10,161,119}
\definecolor{framecolour}{HTML}{009980}


\begin{document}

\begin{frame}[t]{Summary}
\begin{tikzpicture}[remember picture,overlay, scale=0.9, transform shape]
\node[draw, overlay, very thick, rounded corners, fill=green!30, anchor=north west, xshift=12cm, yshift=-0.5cm] at (current page.north west) {hello};
\end{tikzpicture}%
\begin{mytheorem}[colframe=red, text width=10cm,nobeforeafter]{}

\end{mytheorem}

\pause
\begin{enumerate}[<+->] 
\setlength\itemsep{5pt plus 1fill}
\item one
\item two
\item three
\item four
\item five
\item six
\end{enumerate}

\end{frame}

\end{document}
```
![Screen Shot 2021-04-20 at 11.19.01 AM.png](/image?hash=19a1c481e94e55212fb89ff7c7a48f82b9c3ac2c804b5d6b14b63505cc00572d)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.