[Tex/LaTex] How to control margin of the tikzpicture

marginstikz-pgftitles

I have the following code to draw the border of the title page. I want to put the margin for the border on the left and right. How can I set left margin of 1.5 inch and right 1 inch.

\documentclass[12pt, a4, openany, oneside]{book}
\renewcommand{\baselinestretch}{1.6}
\usepackage[left=1.5in,top=1.0in,right=1.0in,bottom=1.0in]{geometry}
%\setlrmarginsandblock{2.5cm}{2.5cm}{*} % Left and right margin
%\setulmarginsandblock{3cm}{3cm}{*}  % Upper and lower margin
%\checkandfixthelayout

\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{5}{\z@}%
            {-2.5ex\@plus -1ex \@minus -.25ex}%
            {1.25ex \@plus .25ex}%
            {\normalfont\normalsize\bfseries}}

\renewcommand\subparagraph{%
 \@startsection {subparagraph}{5}{\z@ }{2.25ex \@plus 1ex
 \@minus .2ex}{-1em}{\normalfont \normalsize \bfseries }}%


\usepackage{enumitem}
\setlistdepth{9} % deep listing to 6th level (9- 6(by default))
\newlist{myenumerate}{enumerate}{9} % deep listing
\setlist[myenumerate]{label*=\arabic*.}
\setlist[enumerate]{label*=\arabic*.} % for default level


%margin
%\usepackage[top=1in, bottom=1in, left=1.25in, right=1.25in]{geometry}


\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage[english]{babel}



\begin{document}


%paragraph spacing
%\setlength{\parskip}{\baselineskip}%

\setlength{\parindent}{0em}
\setlength{\parskip}{1em}

\begin{titlepage}

   \begin{tikzpicture}[remember picture,overlay,inner sep=0.5,outer sep=0]
     \draw[blue!70!black,line width=4pt] ([xshift=-1.5cm,yshift=-2cm]current page.north east) coordinate (A)--([xshift=1.5cm,yshift=-2cm]current page.north west) coordinate(B)--([xshift=1.5cm,yshift=2cm]current page.south west) coordinate (C)--([xshift=-1.5cm,yshift=2cm]current page.south east) coordinate(D)--cycle;

     \draw ([yshift=0.5cm,xshift=-0.5cm]A)-- ([yshift=0.5cm,xshift=0.5cm]B)--
     ([yshift=-0.5cm,xshift=0.5cm]B) --([yshift=-0.5cm,xshift=-0.5cm]B)--([yshift=0.5cm,xshift=-0.5cm]C)--([yshift=0.5cm,xshift=0.5cm]C)--([yshift=-0.5cm,xshift=0.5cm]C)-- ([yshift=-0.5cm,xshift=-0.5cm]D)--([yshift=0.5cm,xshift=-0.5cm]D)--([yshift=0.5cm,xshift=0.5cm]D)--([yshift=-0.5cm,xshift=0.5cm]A)--([yshift=-0.5cm,xshift=-0.5cm]A)--([yshift=0.5cm,xshift=-0.5cm]A);


     \draw ([yshift=-0.3cm,xshift=0.3cm]A)-- ([yshift=-0.3cm,xshift=-0.3cm]B)--
     ([yshift=0.3cm,xshift=-0.3cm]B) --([yshift=0.3cm,xshift=0.3cm]B)--([yshift=-0.3cm,xshift=0.3cm]C)--([yshift=-0.3cm,xshift=-0.3cm]C)--([yshift=0.3cm,xshift=-0.3cm]C)-- ([yshift=0.3cm,xshift=0.3cm]D)--([yshift=-0.3cm,xshift=0.3cm]D)--([yshift=-0.3cm,xshift=-0.3cm]D)--([yshift=0.3cm,xshift=-0.3cm]A)--([yshift=0.3cm,xshift=0.3cm]A)--([yshift=-0.3cm,xshift=0.3cm]A);

   \end{tikzpicture}


\begin{center}





  \vspace{.3cm}
  \textbf{\large{\uppercase{This is the title of the thesis}}}

\end{center}
\end{titlepage}
\end{document} 

enter image description here

Best Answer

The good news is that everything is drawn relative to coordinates (A) (B) (C) and (D). The bad news is that these are not the interior edges. Those (note the corners) are 0.5cm further in.

\documentclass[12pt, a4, openany, oneside]{book}
\renewcommand{\baselinestretch}{1.6}
\usepackage[left=1.5in,top=1.0in,right=1.0in,bottom=1.0in]{geometry}
%\setlrmarginsandblock{2.5cm}{2.5cm}{*} % Left and right margin
%\setulmarginsandblock{3cm}{3cm}{*}  % Upper and lower margin
%\checkandfixthelayout

\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{5}{\z@}%
            {-2.5ex\@plus -1ex \@minus -.25ex}%
            {1.25ex \@plus .25ex}%
            {\normalfont\normalsize\bfseries}}

\renewcommand\subparagraph{%
 \@startsection {subparagraph}{5}{\z@ }{2.25ex \@plus 1ex
 \@minus .2ex}{-1em}{\normalfont \normalsize \bfseries }}%


\usepackage{enumitem}
\setlistdepth{9} % deep listing to 6th level (9- 6(by default))
\newlist{myenumerate}{enumerate}{9} % deep listing
\setlist[myenumerate]{label*=\arabic*.}
\setlist[enumerate]{label*=\arabic*.} % for default level


%margin
%\usepackage[top=1in, bottom=1in, left=1.25in, right=1.25in]{geometry}


\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage[english]{babel}



\begin{document}


%paragraph spacing
%\setlength{\parskip}{\baselineskip}%

\setlength{\parindent}{0em}
\setlength{\parskip}{1em}

\begin{titlepage}

   \begin{tikzpicture}[remember picture,overlay,inner sep=0.5,outer sep=0]
     \path (current page.north east) ++(-1in+0.5cm,-1in+0.5cm) coordinate (A)
           (current page.north west) ++(1.5in-0.5cm,-1in+0.5cm) coordinate (B)
           (current page.south west) ++(1.5in-0.5cm,1in-0.5cm) coordinate (C)
           (current page.south east) ++(-1in+0.5cm,1in-0.5cm) coordinate (D);
     \draw[blue!70!black,line width=4pt] (A)--(B)--(C)--(D)--cycle;

     \draw ([yshift=0.5cm,xshift=-0.5cm]A)-- ([yshift=0.5cm,xshift=0.5cm]B)--
     ([yshift=-0.5cm,xshift=0.5cm]B) --([yshift=-0.5cm,xshift=-0.5cm]B)--([yshift=0.5cm,xshift=-0.5cm]C)--([yshift=0.5cm,xshift=0.5cm]C)--([yshift=-0.5cm,xshift=0.5cm]C)-- ([yshift=-0.5cm,xshift=-0.5cm]D)--([yshift=0.5cm,xshift=-0.5cm]D)--([yshift=0.5cm,xshift=0.5cm]D)--([yshift=-0.5cm,xshift=0.5cm]A)--([yshift=-0.5cm,xshift=-0.5cm]A)--([yshift=0.5cm,xshift=-0.5cm]A);


     \draw ([yshift=-0.3cm,xshift=0.3cm]A)-- ([yshift=-0.3cm,xshift=-0.3cm]B)--
     ([yshift=0.3cm,xshift=-0.3cm]B) --([yshift=0.3cm,xshift=0.3cm]B)--([yshift=-0.3cm,xshift=0.3cm]C)--([yshift=-0.3cm,xshift=-0.3cm]C)--([yshift=0.3cm,xshift=-0.3cm]C)-- ([yshift=0.3cm,xshift=0.3cm]D)--([yshift=-0.3cm,xshift=0.3cm]D)--([yshift=-0.3cm,xshift=-0.3cm]D)--([yshift=0.3cm,xshift=-0.3cm]A)--([yshift=0.3cm,xshift=0.3cm]A)--([yshift=-0.3cm,xshift=0.3cm]A);

   \end{tikzpicture}


\begin{center}





  \vspace{.3cm}
  \textbf{\large{\uppercase{This is the title of the thesis}}}

\end{center}
\end{titlepage}
\end{document}

This solution works for any text area. Just for fun, I got rid of all the [yshift=...,xshift=...] notation and used calc notation instead.

\documentclass[12pt, a4, openany, oneside]{book}
\renewcommand{\baselinestretch}{1.6}
\usepackage[left=1.5in,top=1.0in,right=1.0in,bottom=1.0in]{geometry}
%\setlrmarginsandblock{2.5cm}{2.5cm}{*} % Left and right margin
%\setulmarginsandblock{3cm}{3cm}{*}  % Upper and lower margin
%\checkandfixthelayout

\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{5}{\z@}%
            {-2.5ex\@plus -1ex \@minus -.25ex}%
            {1.25ex \@plus .25ex}%
            {\normalfont\normalsize\bfseries}}

\renewcommand\subparagraph{%
 \@startsection {subparagraph}{5}{\z@ }{2.25ex \@plus 1ex
 \@minus .2ex}{-1em}{\normalfont \normalsize \bfseries }}%


\usepackage{enumitem}
\setlistdepth{9} % deep listing to 6th level (9- 6(by default))
\newlist{myenumerate}{enumerate}{9} % deep listing
\setlist[myenumerate]{label*=\arabic*.}
\setlist[enumerate]{label*=\arabic*.} % for default level


%margin
%\usepackage[top=1in, bottom=1in, left=1.25in, right=1.25in]{geometry}


\usepackage{tikzpagenodes}
\usetikzlibrary{calc}
\usepackage[english]{babel}

\begin{document}

%paragraph spacing
%\setlength{\parskip}{\baselineskip}%

\setlength{\parindent}{0em}
\setlength{\parskip}{1em}

\begin{titlepage}

  \begin{tikzpicture}[remember picture,overlay]
    \path (current page text area.north east) ++(0.5cm,0.5cm) coordinate (A)
          (current page text area.north west) ++(-0.5cm,0.5cm) coordinate (B)
          (current page text area.south west) ++(-0.5cm,-0.5cm) coordinate (C)
          (current page text area.south east) ++(0.5cm,-0.5cm) coordinate (D);
    \draw[blue!70!black,line width=4pt] (A)--(B)--(C)--(D)--cycle;

    \draw ($(A)+(-0.5cm,0.5cm)$)--($(B)+(0.5cm,0.5cm)$)--($(B)+(0.5cm,-0.5cm)$)--($(B)+(-0.5cm,-0.5cm)$)--
          ($(C)+(-0.5cm,0.5cm)$)--($(C)+(0.5cm,0.5cm)$)--($(C)+(0.5cm,-0.5cm)$)--($(D)+(-0.5cm,-0.5cm)$)--
          ($(D)+(-0.5cm,0.5cm)$)--($(D)+(0.5cm,0.5cm)$)--($(A)+(0.5cm,-0.5cm)$)--($(A)+(-0.5cm,-0.5cm)$)--cycle;

    \draw ($(A)+(0.3cm,-0.3cm)$)--($(B)+(-0.3cm,-0.3cm)$)--($(B)+(-0.3cm,0.3cm)$)--($(B)+(0.3cm,0.3cm)$)--
          ($(C)+(0.3cm,-0.3cm)$)--($(C)+(-0.3cm,-0.3cm)$)--($(C)+(-0.3cm,0.3cm)$)--($(D)+(0.3cm,0.3cm)$)--
          ($(D)+(0.3cm,-0.3cm)$)--($(D)+(-0.3cm,-0.3cm)$)--($(A)+(-0.3cm,0.3cm)$)--($(A)+(0.3cm,0.3cm)$)--cycle;
\end{tikzpicture}


\begin{center}

  \vspace{.3cm}
  \textbf{\large{\uppercase{This is the title of the thesis}}}

\end{center}
\end{titlepage}
\end{document} 
Related Question