8

I've starting using TiKZ, just 2 days ago, and I found it beautiful. I've already used \scope, \node etc.

My problem is: How can I start the picture from the upper left corner of the page?

I looked at some syntax guide of TikZ, but I didn't find it.

Can someone help me?

1

1 Answer 1

7

You can use the current page node, either in a drawing or in positioning a drawing.

I will show how to position a drawing to the top left corner of a page, using a node which contains a TikZ drawing. The benefit is, that the inner picture doesn't need to know about the page position at all.

A specialty is, that nodes of the inner drawing inherit options, such as the anchor, from the parent node. So see, how I took care: I stated the node anchor style in the inner drawing, even if center is the default.

\documentclass{article} 
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[remember picture, overlay, transform shape]
  \node [anchor=north west, inner sep=0pt]
    at (current page.north west)
    {
      \begin{tikzpicture}[every node/.append style = {anchor=center}]
        \begin{scope}[blend group = soft light]
          \fill[red!30!white]   ( 90:1.2) circle (2);
          \fill[green!30!white] (210:1.2) circle (2);
          \fill[blue!30!white]  (330:1.2) circle (2);
        \end{scope}
        \node at ( 90:2)    {Typography};
        \node at ( 210:2)   {Design};
        \node at ( 330:2)   {Coding};
        \node [font=\Large] {\LaTeX};
      \end{tikzpicture}
    };
\end{tikzpicture}
\end{document}

Output at the page corner

I took the example from my upcoming LaTeX book, as it was easy for me to grab from my hard disk.

4
  • when i run the code Feb 2021 in Overleaf, the result is different from the picture, the transparency seems not to work
    – Mandragor
    Commented Feb 27, 2021 at 12:59
  • @Mandragor That's a fault of the Overleaf PDF preview function. Click in "Download PDF" on Overleaf and use the Acrobat Reader or another PDF reader to see the transparancy.
    – Stefan Kottwitz
    Commented Feb 27, 2021 at 14:20
  • Why do we need every node/.append style = {anchor=center}?
    – alper
    Commented Jan 8, 2023 at 14:47
  • 1
    @alper That's because the north west anchor would be inherited, as I briefly mentioned in the answer. Adding (again) the center anchor fixes it. Remove it to see what I mean.
    – Stefan Kottwitz
    Commented Jan 8, 2023 at 16:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .