3

I am not good with tikz. I know that this question has already been answered in general (like, for example, here), but I was not able to transfer it to my example. I have the following code:

\documentclass[a4paper]{article}

\usepackage{geometry}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{background}

\usetikzlibrary{calc}
\SetBgScale{1}
\SetBgAngle{0}
\SetBgColor{black}
\SetBgContents{
\begin{tikzpicture}[overlay,remember picture]
    \draw [line width=1pt,rounded corners=17pt,
        ]
        ($ (current page.north west) + (1.2cm,-1cm) $)
        rectangle
        ($ (current page.south east) + (-1cm,2cm) $);
\end{tikzpicture}
}

\begin{document}
\lipsum
\end{document}

Which produces this type of rectangle around the whole page:

enter image description here

How can I make the NW and SE corners NON-rounded? So my special restriction is that I want the rectangle go all around the whole text, relative to the page size.

Duke
  • 389

1 Answers1

7

Just draw two different lines:

  • one from the NW to EW to SE corners
  • the other from the NW to SW to SE corners

With the rounded corners option, only the middle corner will become rounded:

enter image description here

Here's the full code:

\documentclass[a4paper]{article}

\usepackage{geometry}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{background}

\usetikzlibrary{calc}
\SetBgScale{1}
\SetBgAngle{0}
\SetBgColor{black}
\SetBgContents{
  \begin{tikzpicture}[overlay,remember picture]
      \draw [line width=1pt,rounded corners=17pt]
             ($ (current page.north west) + (12mm,-12mm) $)
          -- ($ (current page.north east) + (-12mm,-12mm) $)
          -- ($ (current page.south east) + (-12mm,12mm) $);
      \draw [line width=1pt,rounded corners=17pt]
             ($ (current page.north west) + (12mm,-12mm) $)
          -- ($ (current page.south west) + (12mm,12mm) $)
          -- ($ (current page.south east) + (-12mm,12mm) $);
  \end{tikzpicture}
}

\begin{document}
\lipsum
\end{document}

Edit

As Zarko says in the comments, a better solution is to use:

\SetBgContents{
  \begin{tikzpicture}[overlay,remember picture]
      \draw [line width=1pt,rounded corners=17pt, ]
        ($ (current page.north west) + (12mm,-12mm) $)
          -| ($ (current page.south east) + (-12mm,12mm) $)
             ($ (current page.south east) + (-12mm,12mm) $)
          -| ($ (current page.north west) + (12mm,-12mm) $);
  \end{tikzpicture}
}
  • 2
    or shorter \draw [line width=1pt,rounded corners=17pt, ] ($ (current page.north west) + (1.2cm,-1cm) $) -| ($ (current page.south east) + (-1cm,2cm) $) ($ (current page.south east) + (-1cm,2cm) $) -| ($ (current page.north west) + (1.2cm,-1cm) $); – Zarko Dec 04 '17 at 17:17
  • @Zarko +1 This is nicer than my solution. You should post it. –  Dec 04 '17 at 17:23
  • 2
    no, you bet me for 5 minutes ... you just add this possibilities to your answer ... – Zarko Dec 04 '17 at 17:25