[Tex/LaTex] Placing item right in top left corner on latex beamer title page

beamer

I am trying to create a customized title page with latex beamer. However there seem to be some margins I cannot get rid of.

\documentclass[t,aspectratio=169]{beamer}
\usepackage{tikz}
\defbeamertemplate*{title page}{customized}[1][]{
  \begin{tikzpicture}
    \draw[draw] (0,0) rectangle (16,1);  
  \end{tikzpicture}
}
\begin{document}
  \begin{frame}
    \titlepage
  \end{frame}
\end{document}

I expected the box to be in the top left corner. I tried already with negative vspace which worked to move the box further top, but I do not know which is the correct value. I also could not use vspace and hspace together.

Best Answer

To remove the margins, you could align your rectangle to the corners of the page:

\documentclass[t,aspectratio=169]{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning}

\defbeamertemplate*{title page}{customized}[1][]{
  \begin{tikzpicture}[remember picture,overlay]
  \begin{scope}[shift={(current page.north west)}] 
            \draw[draw] (0,0) rectangle (15.95,-1);   
   \end{scope}
  \end{tikzpicture}
}
\begin{document}
  \begin{frame}
    \titlepage
  \end{frame}
\end{document}

enter image description here


And with automatic width of the box:

\documentclass[t,aspectratio=169]{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}

\defbeamertemplate*{title page}{customized}[1][]{
  \begin{tikzpicture}[remember picture,overlay]
        \coordinate (SW) at (current page.south west);
        \coordinate (SE) at (current page.south east);
        \coordinate (NW) at (current page.north west);
        \coordinate (NE) at (current page.north east);
        \draw[draw] (NW) rectangle ($(NE)!0.2!(SE)$);   
  \end{tikzpicture}
}
\begin{document}
  \begin{frame}
    \titlepage
  \end{frame}
\end{document}