Tikz coordinates relative to one node










5















Using both calc and |- would be a convenient way to refer to "inner, relative coordinates" of a node, with




  • (0, 0) meaning node.center,


  • (0, 1) meaning node.east and


  • (.3, -.5) meaning somewhere precise (but relative) in the south east quarter.

However, as described here and there, the following coordinate is not parsed:



($(node.center)!.3!(node.east)$ |- $(node.center)!-.5!(node.north)$)


So the following convenience macro does not work:



newcommandrelativeToNode[3]- $(#1.center)!#3!(#1.north)$)


How nice would it be to write:



node (inner) at (relativeToNodeouter.3-.5) hey!;


Is there any chance to get this working?

Any workaround that would not involve defining intermediate macros or coordinates (whose names would have to be picked etc.)?










share|improve this question



















  • 1





    tikz doesn't enable calculation of coordinates on the way as you desired. you should defined one auxiliary coordinate: coordinate (aux) at ($(node1.south) + (1,0)$); draw ($(node1.south) + (1,0)$) to (aux |- node2.north);

    – Zarko
    Aug 27 '18 at 9:52











  • @Zarko Well, it seems that it is finally possible like this :)

    – iago-lito
    Aug 27 '18 at 12:15















5















Using both calc and |- would be a convenient way to refer to "inner, relative coordinates" of a node, with




  • (0, 0) meaning node.center,


  • (0, 1) meaning node.east and


  • (.3, -.5) meaning somewhere precise (but relative) in the south east quarter.

However, as described here and there, the following coordinate is not parsed:



($(node.center)!.3!(node.east)$ |- $(node.center)!-.5!(node.north)$)


So the following convenience macro does not work:



newcommandrelativeToNode[3]- $(#1.center)!#3!(#1.north)$)


How nice would it be to write:



node (inner) at (relativeToNodeouter.3-.5) hey!;


Is there any chance to get this working?

Any workaround that would not involve defining intermediate macros or coordinates (whose names would have to be picked etc.)?










share|improve this question



















  • 1





    tikz doesn't enable calculation of coordinates on the way as you desired. you should defined one auxiliary coordinate: coordinate (aux) at ($(node1.south) + (1,0)$); draw ($(node1.south) + (1,0)$) to (aux |- node2.north);

    – Zarko
    Aug 27 '18 at 9:52











  • @Zarko Well, it seems that it is finally possible like this :)

    – iago-lito
    Aug 27 '18 at 12:15













5












5








5


1






Using both calc and |- would be a convenient way to refer to "inner, relative coordinates" of a node, with




  • (0, 0) meaning node.center,


  • (0, 1) meaning node.east and


  • (.3, -.5) meaning somewhere precise (but relative) in the south east quarter.

However, as described here and there, the following coordinate is not parsed:



($(node.center)!.3!(node.east)$ |- $(node.center)!-.5!(node.north)$)


So the following convenience macro does not work:



newcommandrelativeToNode[3]- $(#1.center)!#3!(#1.north)$)


How nice would it be to write:



node (inner) at (relativeToNodeouter.3-.5) hey!;


Is there any chance to get this working?

Any workaround that would not involve defining intermediate macros or coordinates (whose names would have to be picked etc.)?










share|improve this question
















Using both calc and |- would be a convenient way to refer to "inner, relative coordinates" of a node, with




  • (0, 0) meaning node.center,


  • (0, 1) meaning node.east and


  • (.3, -.5) meaning somewhere precise (but relative) in the south east quarter.

However, as described here and there, the following coordinate is not parsed:



($(node.center)!.3!(node.east)$ |- $(node.center)!-.5!(node.north)$)


So the following convenience macro does not work:



newcommandrelativeToNode[3]- $(#1.center)!#3!(#1.north)$)


How nice would it be to write:



node (inner) at (relativeToNodeouter.3-.5) hey!;


Is there any chance to get this working?

Any workaround that would not involve defining intermediate macros or coordinates (whose names would have to be picked etc.)?







tikz-pgf incompatibility coordinates calc relative






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 28 '18 at 9:25







iago-lito

















asked Aug 27 '18 at 9:22









iago-litoiago-lito

677513




677513







  • 1





    tikz doesn't enable calculation of coordinates on the way as you desired. you should defined one auxiliary coordinate: coordinate (aux) at ($(node1.south) + (1,0)$); draw ($(node1.south) + (1,0)$) to (aux |- node2.north);

    – Zarko
    Aug 27 '18 at 9:52











  • @Zarko Well, it seems that it is finally possible like this :)

    – iago-lito
    Aug 27 '18 at 12:15












  • 1





    tikz doesn't enable calculation of coordinates on the way as you desired. you should defined one auxiliary coordinate: coordinate (aux) at ($(node1.south) + (1,0)$); draw ($(node1.south) + (1,0)$) to (aux |- node2.north);

    – Zarko
    Aug 27 '18 at 9:52











  • @Zarko Well, it seems that it is finally possible like this :)

    – iago-lito
    Aug 27 '18 at 12:15







1




1





tikz doesn't enable calculation of coordinates on the way as you desired. you should defined one auxiliary coordinate: coordinate (aux) at ($(node1.south) + (1,0)$); draw ($(node1.south) + (1,0)$) to (aux |- node2.north);

– Zarko
Aug 27 '18 at 9:52





tikz doesn't enable calculation of coordinates on the way as you desired. you should defined one auxiliary coordinate: coordinate (aux) at ($(node1.south) + (1,0)$); draw ($(node1.south) + (1,0)$) to (aux |- node2.north);

– Zarko
Aug 27 '18 at 9:52













@Zarko Well, it seems that it is finally possible like this :)

– iago-lito
Aug 27 '18 at 12:15





@Zarko Well, it seems that it is finally possible like this :)

– iago-lito
Aug 27 '18 at 12:15










1 Answer
1






active

oldest

votes


















6














For your use case you don't even need the calc library. You can define style relative to node=<node name> that shifts and scales the coordinate system accordingly:



tikzset
relative to node/.style=
shift=(#1.center),
x=(#1.east),
y=(#1.north),




Then you can place your node with



path[relative to node=outer] (-0.4,-0.5) node Hello;


MWE:



documentclass[tikz,margin=2mm]standalone

tikzset
relative to node/.style=
shift=(#1.center),
x=(#1.east),
y=(#1.north),



begindocument
begintikzpicture
node[minimum width=2cm,minimum height=3cm,draw=red] (outer) at (3,3) ;

% Only for the grid
beginscope[relative to node=outer]
foreach ratio in -1,-0.8,...,1
draw[help lines] (-1,ratio) -- (1,ratio);
draw[help lines] (ratio,-1) -- (ratio,1);

draw (-1,0) -- (1,0);
draw (0,-1) -- (0,1);
endscope

path[relative to node=outer] (-0.4,-0.5) node Hello;

endtikzpicture
enddocument


Resulting in



enter image description here






share|improve this answer


















  • 1





    Awesome, thanks :) Since this is not my core problem, but the core problem has no solution according to Zarko, I'll edit the OP so it matches your answer best.

    – iago-lito
    Aug 27 '18 at 9:59










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f447925%2ftikz-coordinates-relative-to-one-node%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









6














For your use case you don't even need the calc library. You can define style relative to node=<node name> that shifts and scales the coordinate system accordingly:



tikzset
relative to node/.style=
shift=(#1.center),
x=(#1.east),
y=(#1.north),




Then you can place your node with



path[relative to node=outer] (-0.4,-0.5) node Hello;


MWE:



documentclass[tikz,margin=2mm]standalone

tikzset
relative to node/.style=
shift=(#1.center),
x=(#1.east),
y=(#1.north),



begindocument
begintikzpicture
node[minimum width=2cm,minimum height=3cm,draw=red] (outer) at (3,3) ;

% Only for the grid
beginscope[relative to node=outer]
foreach ratio in -1,-0.8,...,1
draw[help lines] (-1,ratio) -- (1,ratio);
draw[help lines] (ratio,-1) -- (ratio,1);

draw (-1,0) -- (1,0);
draw (0,-1) -- (0,1);
endscope

path[relative to node=outer] (-0.4,-0.5) node Hello;

endtikzpicture
enddocument


Resulting in



enter image description here






share|improve this answer


















  • 1





    Awesome, thanks :) Since this is not my core problem, but the core problem has no solution according to Zarko, I'll edit the OP so it matches your answer best.

    – iago-lito
    Aug 27 '18 at 9:59















6














For your use case you don't even need the calc library. You can define style relative to node=<node name> that shifts and scales the coordinate system accordingly:



tikzset
relative to node/.style=
shift=(#1.center),
x=(#1.east),
y=(#1.north),




Then you can place your node with



path[relative to node=outer] (-0.4,-0.5) node Hello;


MWE:



documentclass[tikz,margin=2mm]standalone

tikzset
relative to node/.style=
shift=(#1.center),
x=(#1.east),
y=(#1.north),



begindocument
begintikzpicture
node[minimum width=2cm,minimum height=3cm,draw=red] (outer) at (3,3) ;

% Only for the grid
beginscope[relative to node=outer]
foreach ratio in -1,-0.8,...,1
draw[help lines] (-1,ratio) -- (1,ratio);
draw[help lines] (ratio,-1) -- (ratio,1);

draw (-1,0) -- (1,0);
draw (0,-1) -- (0,1);
endscope

path[relative to node=outer] (-0.4,-0.5) node Hello;

endtikzpicture
enddocument


Resulting in



enter image description here






share|improve this answer


















  • 1





    Awesome, thanks :) Since this is not my core problem, but the core problem has no solution according to Zarko, I'll edit the OP so it matches your answer best.

    – iago-lito
    Aug 27 '18 at 9:59













6












6








6







For your use case you don't even need the calc library. You can define style relative to node=<node name> that shifts and scales the coordinate system accordingly:



tikzset
relative to node/.style=
shift=(#1.center),
x=(#1.east),
y=(#1.north),




Then you can place your node with



path[relative to node=outer] (-0.4,-0.5) node Hello;


MWE:



documentclass[tikz,margin=2mm]standalone

tikzset
relative to node/.style=
shift=(#1.center),
x=(#1.east),
y=(#1.north),



begindocument
begintikzpicture
node[minimum width=2cm,minimum height=3cm,draw=red] (outer) at (3,3) ;

% Only for the grid
beginscope[relative to node=outer]
foreach ratio in -1,-0.8,...,1
draw[help lines] (-1,ratio) -- (1,ratio);
draw[help lines] (ratio,-1) -- (ratio,1);

draw (-1,0) -- (1,0);
draw (0,-1) -- (0,1);
endscope

path[relative to node=outer] (-0.4,-0.5) node Hello;

endtikzpicture
enddocument


Resulting in



enter image description here






share|improve this answer













For your use case you don't even need the calc library. You can define style relative to node=<node name> that shifts and scales the coordinate system accordingly:



tikzset
relative to node/.style=
shift=(#1.center),
x=(#1.east),
y=(#1.north),




Then you can place your node with



path[relative to node=outer] (-0.4,-0.5) node Hello;


MWE:



documentclass[tikz,margin=2mm]standalone

tikzset
relative to node/.style=
shift=(#1.center),
x=(#1.east),
y=(#1.north),



begindocument
begintikzpicture
node[minimum width=2cm,minimum height=3cm,draw=red] (outer) at (3,3) ;

% Only for the grid
beginscope[relative to node=outer]
foreach ratio in -1,-0.8,...,1
draw[help lines] (-1,ratio) -- (1,ratio);
draw[help lines] (ratio,-1) -- (ratio,1);

draw (-1,0) -- (1,0);
draw (0,-1) -- (0,1);
endscope

path[relative to node=outer] (-0.4,-0.5) node Hello;

endtikzpicture
enddocument


Resulting in



enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered Aug 27 '18 at 9:56









MaxMax

6,65321830




6,65321830







  • 1





    Awesome, thanks :) Since this is not my core problem, but the core problem has no solution according to Zarko, I'll edit the OP so it matches your answer best.

    – iago-lito
    Aug 27 '18 at 9:59












  • 1





    Awesome, thanks :) Since this is not my core problem, but the core problem has no solution according to Zarko, I'll edit the OP so it matches your answer best.

    – iago-lito
    Aug 27 '18 at 9:59







1




1





Awesome, thanks :) Since this is not my core problem, but the core problem has no solution according to Zarko, I'll edit the OP so it matches your answer best.

– iago-lito
Aug 27 '18 at 9:59





Awesome, thanks :) Since this is not my core problem, but the core problem has no solution according to Zarko, I'll edit the OP so it matches your answer best.

– iago-lito
Aug 27 '18 at 9:59

















draft saved

draft discarded
















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f447925%2ftikz-coordinates-relative-to-one-node%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)