2

Another minimal example:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}

\node[draw=black,%
rounded corners=2pt,%
rectangle,%
bottom color=black!80!white] (A) {node aligned on left margin}; 

\node[draw=black,%
rounded corners=2pt,% 
rectangle,% 
bottom color=black!80!white] {node aligned on the right margin};


\end{tikzpicture}
\end{document}

in this case I'd like to have the first node aligned on the left margin of the paper and the second one on the right.

1

I suggest you try it this way:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\path (0,0) node[draw=black, rounded corners=2pt, rectangle, bottom color=black!80!white, anchor=west] (A) {node aligned on left margin} -- (\textwidth,0) node[draw=black, rounded corners=2pt, rectangle, bottom color=black!80!white, anchor=east] (B) {node aligned on the right margin};
\end{tikzpicture}
\end{document}

The nodes are on a path, which spans the width of the text on the page (\textwidth).

The anchors of the nodes are necessary to make sure the nodes do not get off the page.

  • 1
    Instead of anchor=west,anchor=east I find right,left to be more intuitive. – Peter Grill Sep 28 '11 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.