6

I'm trying to place certain objects on my page. Normally you can use the shift argument to place the object at a set of coordinates, or even current page. None of that seems functional with the following piece of code:

\documentclass{article}
\usepackage[a4paper]{geometry}
\usepackage[usenames,dvipsnames]{color}
\usepackage{tikz}
\usetikzlibrary{fadings,shapes.arrows,curvilinear,shadings}
\usepgfmodule{nonlineartransformations}
\pagenumbering{gobble}

\definecolor{lightblue}{RGB}{51,127,230}
\definecolor{olive2}{RGB}{64,196,0}
\definecolor{dorange}{RGB}{255,140,0}

\tikzfading[name=arrowfading, left color=transparent!0, right color=transparent!35]
\tikzset{
arrownode/.style={
    transform shape nonlinear=true,
    shape=double arrow, 
    line width=10mm,
    shape border rotate=180,
    upper left=cyan!25,
    lower left=dorange!5,
    upper right=olive!35,
    lower right=dorange!20,
    path fading=arrowfading
}
}
\makeatletter
\def\polartransformation{% I'll probably need another transformation? I can't find anything in the PGF manual on using a third variable
\pgfmathsincos@{\pgf@x}
\pgf@x=\pgfmathresultx\pgf@y%
\pgf@y=\pgfmathresulty\pgf@y%
}
\makeatother

\begin{document}
\centering
\begin{tikzpicture}
\begin{scope}[remember picture,overlay]% I want to use shift={<argument>} here in CARTESIAN COORDINATES.
\pgftransformnonlinear{\polartransformation}
%%%%%%%%%%%%%% Draw the node
\node[arrownode,shading angle=0] (a) at (1.5*pi,-5) {\phantom{\hspace{2cm}Gleidende schaal\hspace{4cm}}};
\end{scope}
\end{tikzpicture}
\end{document}

How do I get this thing to go to for instance (-5,-5)?

1010011010
  • 6,357
  • Add shift={(5,-5)} to the scope options. – percusse Apr 13 '14 at 17:05
  • That's another interesting problem! It looks that you need inverse transformation function. Ah, maybe not... – Malipivo Apr 13 '14 at 17:05
  • I most certainly tried to add shift to the scope options. This shape is rock solid rooted in place. – 1010011010 Apr 13 '14 at 17:13
  • because there is nothing else in the picture so even if you move it tikz will truncate it. Add a node somewhere else and you'll see. – percusse Apr 13 '14 at 22:02
  • I've tried placing the object in my actual picture. The fact even aligning with the node current page.south yields no results should be sufficient to exclude that simple solution. EDIT: I'll post some screenshots for clarification. i.imgur.com/46fltCM.png?1 EDIT2: I noticed that it may not be completely clear. I can use any node within this project and it will always lock in place at cartesian coordinates (0,0). – 1010011010 Apr 13 '14 at 22:30
  • I can move the image around outside of tikz with, for example, \begin{document} \centering \setbox0=\hbox{% \begin{tikzpicture} \begin{scope}[remember picture,overlay]% I want to use shift={<argument>} here in CARTESIAN COORDINATES. \pgftransformnonlinear{\polartransformation} %%%%%%%%%%%%%% Draw the node \node[arrownode,shading angle=0] (a) at (1.5*pi,-5) {\phantom{\hspace{2cm}Gleidende schaal\hspace{4cm}}}; \end{scope} \end{tikzpicture}% }\vspace*{4in}\hspace{2in}\box0 \end{document} But would that work for your needs? – Steven B. Segletes Apr 14 '14 at 00:39
  • I tried your workaround, but can't seem to get the vspace part to work? The hbox part is working just fine. And yes, I suppose this would work if the vspace part would simply move my picture around. – 1010011010 Apr 14 '14 at 00:52
  • If you want me to be notified of your comment you need to include @StevenB.Segletes as part of your comment. As far as the \vspace, did you remember to make it the starred version \vspace*? If you did use the * and it still didn't work, that would be most strange. There are other ways to move it down, if you still can't get it to work. I'll check back in tomorrow. – Steven B. Segletes Apr 14 '14 at 02:37
  • ...for example, a \raisebox, as in \begin{document} \centering \setbox0=\hbox{% \begin{tikzpicture} \begin{scope}[remember picture,overlay]% I want to use shift={<argument>} here in CARTESIAN COORDINATES. \pgftransformnonlinear{\polartransformation} %%%%%%%%%%%%%% Draw the node \node[arrownode,shading angle=0] (a) at (1.5*pi,-5) {\phantom{\hspace{2cm}Gleidende schaal\hspace{4cm}}}; \end{scope} \end{tikzpicture}% }\raisebox{-4in}{\hspace{2in}\box0} \end{document} – Steven B. Segletes Apr 14 '14 at 02:39
  • @StevenB.Segletes Although yes this does work, it creates a new page. That's kind of what I meant with "this workaround doesn't work for me". Sorry! I've tried \nopagebreak and \begin{samepage} but LaTeX doesn't seem to care much about that. I've also tried \raisebox but this also creates a new page, also in combination with any of these other commands to discourage a pagebreak. – 1010011010 Apr 14 '14 at 08:21
  • @Euryris I will delete my answer, unless I can solve the page breaking problem. – Steven B. Segletes Apr 14 '14 at 10:12
  • @StevenB.Segletes Is there no way to differentiate between coordinate systems between 1) de determining of the shape and 2) de placement of the object? It sounds like such a straightforward task, yet such a robust answer to all this . . . EDIT: maybe I should just post all my code, so solvers can properly assess whether this method will work? – 1010011010 Apr 14 '14 at 10:31
  • @Euryris I am not a tikz guy, so any answer I give will necessarily be outside of the logic of tikz. For that reason, my answer would be less desirable than one that someone could solve inside of tikz. – Steven B. Segletes Apr 14 '14 at 11:13
  • Please see revision. – Steven B. Segletes Apr 14 '14 at 11:25

2 Answers2

4

I REVISED my solution to use the approach of What are the ways to position things absolutely on the page? to place an object by specifying the absolute paper coordinates. I placed the object as a "watermark", but it is not clear to me if that is or is not what you want, or whether it could be adapted to your needs.

\documentclass{article}
\usepackage[a4paper]{geometry}
\usepackage[usenames,dvipsnames]{color}
\usepackage{tikz}
\usetikzlibrary{fadings,shapes.arrows,curvilinear,shadings}
\usepgfmodule{nonlineartransformations}
\pagenumbering{gobble}

\definecolor{lightblue}{RGB}{51,127,230}
\definecolor{olive2}{RGB}{64,196,0}
\definecolor{dorange}{RGB}{255,140,0}

\tikzfading[name=arrowfading, left color=transparent!0, right color=transparent!35]
\tikzset{
arrownode/.style={
    transform shape nonlinear=true,
    shape=double arrow, 
    line width=10mm,
    shape border rotate=180,
    upper left=cyan!25,
    lower left=dorange!5,
    upper right=olive!35,
    lower right=dorange!20,
    path fading=arrowfading
}
}
\makeatletter
\def\polartransformation{% I'll probably need another transformation? I can't find anything in the PGF manual on using a third variable
\pgfmathsincos@{\pgf@x}
\pgf@x=\pgfmathresultx\pgf@y%
\pgf@y=\pgfmathresulty\pgf@y%
}
\makeatother
\usepackage{lipsum}
\usepackage{everypage}
\def\PageTopMargin{1in}
\def\PageLeftMargin{1in}
\newcommand\atxy[3]{%
 \AddThispageHook{\smash{\hspace*{\dimexpr-\PageLeftMargin-\hoffset+#1\relax}%
  \raisebox{\dimexpr\PageTopMargin+\voffset-#2\relax}{\textcolor{red}{#3}}}}}
\begin{document}
\lipsum[1]
\atxy{4.25in}{5.5in}{%SHIFT IS ACCOMPLISHED HERE IN CARTESIAN (PAPER COORDINATES)
\begin{tikzpicture}
\begin{scope}[remember picture,overlay]% I want to use shift={<argument>} here in CARTESIAN COORDINATES.
\pgftransformnonlinear{\polartransformation}
%%%%%%%%%%%%%% Draw the node
\node[arrownode,shading angle=0] (a) at (1.5*pi,-5) {\phantom{\hspace{2cm}Gleidende schaal\hspace{4cm}}};
\end{scope}
\end{tikzpicture}%
}
\lipsum[2]
\end{document}

enter image description here

If one does not want it as a watermark effect, then a proper use of \vspace or some other space skipping mechanism (e.g., immediately before \lipsum[2]) would allow the figure to be isolated:

enter image description here

  • ah ok now I see it. Yes it is the way to go. I was thinking of placing inside the tikzpicture but this is placing THE tikz picture. – percusse Apr 14 '14 at 11:33
  • @percusse Issuing a \vspace{5in} prior to \lipsum[2] will place the text around the figure, rather than overlay it. It will require some extra calculation on one's part if one does not want overlays, but it would give one the necessary control. – Steven B. Segletes Apr 14 '14 at 11:35
  • Yeah, this is pretty much what I wanted. I think referring to this node from another tikzpicture can still be done using macros (?). Regardless, this is pretty much as robust as I would need my solution. Thank you. – 1010011010 Apr 14 '14 at 11:57
1

After fiddling around a little and asking around as well, I've come to the following answer: in tikz-pgf it is possible to embed nodes into another node:

\draw (0,0) node {\begin{tikzpicture}

\begin{scope}[remember picture,overlay] \pgftransformnonlinear{\polartransformation}

\node[arrownode,shading angle=0] (a) at (1.5*pi,-5) {\phantom{\hspace{2cm}Gleidende schaal\hspace{4cm}}};



\path[decorate,decoration={text along path,text format delimiters={[}{]},

           text={[\Huge]GLEIDENDE SCHAAL},

            text align={fit to path},

            raise=-2ex,

          }](a.west) -- (a.east);

\end{scope}

\end{tikzpicture}};

This also allows you to refer to this node within the same picture.

1010011010
  • 6,357