# How to draw a tikzpicture with text width but have single nodes on page margin?

I'd like to draw a tikz picture which exactly fits the text width, which I achieve by just using multiples of \textwidth for all x-dimensions inside the picture.

However, there are some nodes that I want to place on the page margin. Preferably within the same tikzpicture (but not necessarily). What is the proper way to do it?

I know I could workaround that with scaling the tikzpicture and resizing the box afterwards, until it fits, but that solution does not feel right. I'm thinking more on a solution with nodes, which are not considered for the determination of the total width of the tikzpicture.

## MWE

\documentclass{beamer}

\usepackage{tikz}
\usepackage{kantlipsum}

\begin{document}
\begin{frame}

\kant[9]

\def\rh{1cm}
\def\rw{\textwidth}
\begin{tikzpicture}
\node[  minimum width = \rw, minimum height = \rh,
draw = blue, thick,
fill opacity = 0.3, text opacity = 1,
align = center] (A1) at (0,0) {Block with text width};
\end{tikzpicture}

\begin{tikzpicture}
\node[  minimum width = \rw, minimum height = \rh,
draw = blue, thick,
fill opacity = 0.3, text opacity = 1,
align = center] (A2) at (0,0) {Block with text width};
\node[circle,left] at (A1.west) {A};
\node[circle,right] at (A2.east) {B};
\end{tikzpicture}

\end{frame}
\end{document}


I don't know what's proper, but you can use \useasboundingbox as below before you add the elements in the margins. Then they will not considered when LaTeX places the tikzpicture.

\documentclass{beamer}

\usepackage{tikz}
\usepackage{kantlipsum}

\begin{document}
\begin{frame}

\kant[9]

\def\rh{1cm}
\def\rw{\textwidth}
\begin{tikzpicture}
\node[  minimum width = \rw, minimum height = \rh,
draw = blue, thick,
fill opacity = 0.3, text opacity = 1,
align = center] (A1) at (0,0) {Block with text width};
\end{tikzpicture}

\begin{tikzpicture}

\node[  minimum width = \rw, minimum height = \rh,
draw = blue, thick,
fill opacity = 0.3, text opacity = 1,
align = center] (A2) at (0,0) {Block with text width};

% everything after this is in the margins

\useasboundingbox (current bounding box.south east) rectangle (current bounding box.north west);
\node[circle,left] at (A1.west) {A};
\node[circle,right] at (A2.east) {B};
\end{tikzpicture}

\end{frame}
\end{document}