Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to make the "Legend" appear on the right hand side of the drawing...Any suggestions? I tried playing around with the anchoring direction and slope to no avail.

 \documentclass[tikz,border=10pt]{standalone}
    \usepackage{amssymb}
    \usetikzlibrary{positioning}
    \begin{document}

    \begin{center}
      \begin{tikzpicture}
        \foreach \x/\y/\z in {1/1/9,3.2/1/10,2/1.5/8,1.5/2/6, 2.5/2/7,1.2/2.5/2,2/2.5/4,3.1/2.5/5,2/3/1,2.9/2.9/3}{
        \node[circle,fill,inner sep=1.5pt,outer sep=0pt,label={[xshift=-3pt,yshift=2pt,scale=0.7]-60:$\mathrm{P}_{\z}$}] (\z) at (\x,\y){};
        }
        \node[draw,rectangle,anchor=south west,minimum width=4cm,minimum height=4cm] (A) at (0,0) {};
        \node[draw,rectangle,top color=white,bottom color=gray!60,anchor=south west,minimum width=4cm,minimum height=4cm] (B) at (1.3,5) {};
        \draw (A.north west) -- (B.north west)
              (A.north east) -- (B.north east)
              (A.south west) -- (B.south west)
              (A.south east) -- (B.south east);
        \node (U) at (-1,5) {$\mathrm{U}_1$};
        \node at (-1,2) {$\mathrm{U}_2$};
        \draw (U.east) edge[bend left] (1.west);
        \draw (U.east) edge[bend right] (2.south);
        \node[anchor=west] at (0,-1) {Legend:};
        \node[anchor=west] at (0,-1.5) {{\tiny$\blacksquare$} $\mathrm{U}_1$ - instantiated universal};
        \node[anchor=west] at (0,-2) {{\tiny$\blacksquare$} $\mathrm{U}_2$ - uninstantiated universal};
        \node[anchor=west] at (0,-2.5) {{\tiny$\blacksquare$} $\mathrm{P}_1 \ldots \mathrm{P}_2$ - thin particulars};
        \node[anchor=west] at (0,-3) {{\tiny$\blacksquare$} $\mathrm{P}_3 \ldots \mathrm{P}_{10}$ - bare particulars};
        \node[anchor=center,above = 0.1cm of B.north west,font=\bfseries\large] {Space-time manifold}; 

    \end{tikzpicture}
    \end{center}

    \end{document}
share|improve this question

4 Answers 4

You can use positioning library (which you already loaded).

 \documentclass[tikz,border=10pt]{standalone}
    \usepackage{amssymb}
    \usetikzlibrary{positioning}
    \begin{document}
      \begin{tikzpicture}
        \foreach \x/\y/\z in {1/1/9,3.2/1/10,2/1.5/8,1.5/2/6, 2.5/2/7,1.2/2.5/2,2/2.5/4,3.1/2.5/5,2/3/1,2.9/2.9/3}{
        \node[circle,fill,inner sep=1.5pt,outer sep=0pt,label={[xshift=-3pt,yshift=2pt,scale=0.7]-60:$\mathrm{P}_{\z}$}] (\z) at (\x,\y){};
        }
        \node[draw,rectangle,anchor=south west,minimum width=4cm,minimum height=4cm] (A) at (0,0) {};
        \node[draw,rectangle,top color=white,bottom color=gray!60,anchor=south west,minimum width=4cm,minimum height=4cm] (B) at (1.3,5) {};
        \draw (A.north west) -- (B.north west)
              (A.north east) -- (B.north east)
              (A.south west) -- (B.south west)
              (A.south east) -- (B.south east);
        \node (U) at (-1,5) {$\mathrm{U}_1$};
        \node at (-1,2) {$\mathrm{U}_2$};
        \draw (U.east) edge[bend left] (1.west);
        \draw (U.east) edge[bend right] (2.south);
        \node[anchor=west,below right = 0cm and   1cm of B]  {Legend:};
        \node[anchor=west,below right = 0.5cm and   1.25cm of B]  {{\tiny$\blacksquare$} $\mathrm{U}_1$ - instantiated universal};
        \node[anchor=west,below right = 1cm and   1.25cm of B] {{\tiny$\blacksquare$} $\mathrm{U}_2$ - uninstantiated universal};
        \node[anchor=west,below right = 1.5cm and   1.25cm of B] {{\tiny$\blacksquare$} $\mathrm{P}_1 \ldots \mathrm{P}_2$ - thin particulars};
        \node[anchor=west,below right = 2cm and   1.25cm of B] {{\tiny$\blacksquare$} $\mathrm{P}_3 \ldots \mathrm{P}_{10}$ - bare particulars};
        \node[anchor=center,above = 0.1cm of B.north west,font=\bfseries\large] {Space-time manifold};

    \end{tikzpicture}

    \end{document}

enter image description here

Adjus the values in below right = 2cm and 1.25cm of B suitably as you like. The first value is below value and the second one is right value.

share|improve this answer

Would this be close to what you need? Use of scope environment wrapping your legend in side and apply [shift={(xx,yy)}] to suit your needs for the locations. Furthermore, for the title manifold, you can use xshift=xx to move it to the right.

enter image description here

Code

\documentclass[tikz,border=10pt]{standalone}
    \usepackage{amssymb}
    \usetikzlibrary{positioning}
    \begin{document}

    \begin{center}
      \begin{tikzpicture}
        \foreach \x/\y/\z in {1/1/9,3.2/1/10,2/1.5/8,1.5/2/6, 2.5/2/7,1.2/2.5/2,2/2.5/4,3.1/2.5/5,2/3/1,2.9/2.9/3}{
        \node[circle,fill,inner sep=1.5pt,outer sep=0pt,label={[xshift=-3pt,yshift=2pt,scale=0.7]-60:$\mathrm{P}_{\z}$}] (\z) at (\x,\y){};
        }
        \node[draw,rectangle,anchor=south west,minimum width=4cm,minimum height=4cm] (A) at (0,0) {};
        \node[draw,rectangle,top color=white,bottom color=gray!60,anchor=south west,minimum width=4cm,minimum height=4cm] (B) at (1.3,5) {};
        \draw (A.north west) -- (B.north west)
              (A.north east) -- (B.north east)
              (A.south west) -- (B.south west)
              (A.south east) -- (B.south east);
        \node (U) at (-1,5) {$\mathrm{U}_1$};
        \node at (-1,2) {$\mathrm{U}_2$};
\begin{scope}[shift={(6cm,5cm)}]
        \draw (U.east) edge[bend left] (1.west);
        \draw (U.east) edge[bend right] (2.south);
        \node[anchor=west] at (0,-1) {Legend:};
        \node[anchor=west] at (0,-1.5) {{\tiny$\blacksquare$} $\mathrm{U}_1$ - instantiated universal};
        \node[anchor=west] at (0,-2) {{\tiny$\blacksquare$} $\mathrm{U}_2$ - uninstantiated universal};
        \node[anchor=west] at (0,-2.5) {{\tiny$\blacksquare$} $\mathrm{P}_1 \ldots \mathrm{P}_2$ - thin particulars};
        \node[anchor=west] at (0,-3) {{\tiny$\blacksquare$} $\mathrm{P}_3 \ldots \mathrm{P}_{10}$ - bare particulars};
\end{scope}
        \node[anchor=center,above = 0.1cm of B.north west,font=\bfseries\large, xshift=1cm] {Space-time manifold}; 
    \end{tikzpicture}
    \end{center}

    \end{document}
share|improve this answer

Something like this?

You don't need to place every label component but use only one node with all legend inside. If you fix some node's text width TiKZ will break lines accordingly, but you can also use \\ to break them.

enter image description here

 \documentclass[tikz,border=10pt]{standalone}
    \usepackage{amssymb}
    \usetikzlibrary{positioning}
    \begin{document}
      \begin{tikzpicture}
        \foreach \x/\y/\z in {1/1/9,3.2/1/10,2/1.5/8,1.5/2/6, 2.5/2/7,1.2/2.5/2,2/2.5/4,3.1/2.5/5,2/3/1,2.9/2.9/3}{
        \node[circle,fill,inner sep=1.5pt,outer sep=0pt,label={[xshift=-3pt,yshift=2pt,scale=0.7]-60:$\mathrm{P}_{\z}$}] (\z) at (\x,\y){};
        }
        \node[draw,rectangle,anchor=south west,minimum width=4cm,minimum height=4cm] (A) at (0,0) {};
        \node[draw,rectangle,top color=white,bottom color=gray!60,anchor=south west,minimum width=4cm,minimum height=4cm] (B) at (1.3,5) {};
        \draw (A.north west) -- (B.north west)
              (A.north east) -- (B.north east)
              (A.south west) -- (B.south west)
              (A.south east) -- (B.south east);
        \node (U) at (-1,5) {$\mathrm{U}_1$};
        \node at (-1,2) {$\mathrm{U}_2$};
        \draw (U.east) edge[bend left] (1.west);
        \draw (U.east) edge[bend right] (2.south);
        \node[anchor=west, text width=5cm, right=1cm of B.east] {Legend:\\ {\tiny$\blacksquare$} $\mathrm{U}_1$ - instantiated universal \\ {\tiny$\blacksquare$} $\mathrm{U}_2$ - uninstantiated universal\\ {\tiny$\blacksquare$} $\mathrm{P}_1 \ldots \mathrm{P}_2$ - thin particulars\\ {\tiny$\blacksquare$} $\mathrm{P}_3 \ldots \mathrm{P}_{10}$ - bare particulars};

        %\node[anchor=west] at (0,-1) {Legend:};
        %\node[anchor=west] at (0,-1.5) {{\tiny$\blacksquare$} $\mathrm{U}_1$ - instantiated universal};
        %\node[anchor=west] at (0,-2) {{\tiny$\blacksquare$} $\mathrm{U}_2$ - uninstantiated universal};
        %\node[anchor=west] at (0,-2.5) {{\tiny$\blacksquare$} $\mathrm{P}_1 \ldots \mathrm{P}_2$ - thin particulars};
        %\node[anchor=west] at (0,-3) {{\tiny$\blacksquare$} $\mathrm{P}_3 \ldots \mathrm{P}_{10}$ - bare particulars};
        \node[anchor=center,above = 0.1cm of B.north west,font=\bfseries\large] {Space-time manifold}; 
    \end{tikzpicture}

    \end{document}
share|improve this answer

Here is a soltuion where the legend is positioned relative to the north west corner of the bounding box of the drawing:

\documentclass[tikz,border=10pt]{standalone}

\usepackage{amssymb}

\usetikzlibrary{positioning, calc}

\begin{document}

\begin{center}
    \begin{tikzpicture}
        % Create a scope which includes the drawing (figure) and the legend
        \begin{scope}[local bounding box=figure_with_legend]
            \foreach \x/\y/\z in {1/1/9, 3.2/1/10, 2/1.5/8, 1.5/2/6, 2.5/2/7, 1.2/2.5/2, 2/2.5/4, 3.1/2.5/5, 2/3/1, 2.9/2.9/3}{
                \node[circle,%
                    fill,%
                    inner sep=1.5pt,%
                    outer sep=0pt,%
                    label={[xshift=-3pt,%
                        yshift=2pt,%
                        scale=0.7]-60:$\mathrm{P}_{\z}$}] (\z) at (\x,\y){};
            }
            \node[draw,%
                rectangle,%
                anchor=south west,%
                minimum width=4cm,%
                minimum height=4cm] (A) at (0,0) {};
            \node[draw,%
            rectangle,%
            top color=white,%
            bottom color=gray!60,%
            anchor=south west,%
            minimum width=4cm,%
            minimum height=4cm] (B) at (1.3,5) {};
            \draw (A.north west) -- (B.north west)
                (A.north east) -- (B.north east)
                (A.south west) -- (B.south west)
                (A.south east) -- (B.south east);
            \node (U) at (-1,5) {$\mathrm{U}_1$};
            \node at (-1,2) {$\mathrm{U}_2$};
            \draw (U.east) edge[bend left] (1.west);
            \draw (U.east) edge[bend right] (2.south);

            % Place the legend relative of the north east corner of the drawing
            \node[anchor=north west,%
                align=left] (legend_title) at ($(current bounding box.north east) + (0.5, 0)$) {Legend:};
            \node[below=0.20 of legend_title,%
                anchor= west] {{\tiny$\blacksquare$} $\mathrm{U}_1$ -- instantiated universal};
            \node[below=0.70 of legend_title,%
                anchor=west] {{\tiny$\blacksquare$} $\mathrm{U}_2$ -- uninstantiated universal};
            \node[below=1.20 of legend_title,%
                anchor=west] {{\tiny$\blacksquare$} $\mathrm{P}_1 \ldots \mathrm{P}_2$ -- thin particulars};
            \node[below=1.70 of legend_title,%
                anchor=west] {{\tiny$\blacksquare$} $\mathrm{P}_3 \ldots \mathrm{P}_{10}$ -- bare particulars};
        \end{scope}

        % Place the title centered above the drawing and the legend
        \node[align=center,%
            anchor=center,%
            above=of figure_with_legend,%
            font=\bfseries\large] {Space-time manifold};
    \end{tikzpicture}
\end{center}

\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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