1

How do I correct the 3 lines with \node expressions immediately preceding \end{tikzpicture} so that the indicated "labels" a, b, c are near the points described in the trailing comments there?

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{arrows.meta,decorations.markings,plotmarks}

\begin{document}

\begin{tikzpicture}[
    middlearrow/.style 2 args={
        decoration={markings, mark=at position 0.5 with {\arrow{>}, \node[#1]{#2};}
        },
        postaction={decorate}
    },
]
\draw (0,0) rectangle (4,4);
\draw (0,4) -- (2, 0) -- (4, 4);
\draw[middlearrow={below}{$\sigma$}]    (0,0) -- (2,0);
\draw[middlearrow={below}{$\sigma$}]    (4,0) -- (2,0);
\draw[middlearrow={above}{$\nu_{x}$}]   (0,4) -- (4,4);
\draw[middlearrow={right}{$\sigma$}]    (0,4) -- (2,0);
\draw[middlearrow={right}{$\sigma$}]    (4,4) -- (2,0);
(0,0) \node[anchor=north east] {$x$};
(4,0) \node[anchor=north west] {$a$};  % want it near corner (4, 0)
(0,2) \node[anchor=east]{$b$};        % want it near point (0, 2)
(4,2) \node[anchor=west]{$c$};        % want it near point (4, 2)
\end{tikzpicture}

\end{document}

Misplaced labels at three points

Please be gentle! I realize that this is a very basic question. But I'm a rank beginner at TikZ and still trying to comprehend its weird mixture of several different syntactical schemes and bewildering supply of commands, actions, and options.

Note: If you can suggest any simplifications to the code, I'd appreciate that, too!

1
  • 1
    use either \draw (4,0) node {$a$}; or \node at (4,0) {$a$}; – nidhin Oct 1 '20 at 17:46
1

To place a node at some coordinate, you can use either \node

\node at (0,0) {origin};

or \draw

\draw (0,0) node {origin};

So the last four lines have to be rewritten.

\draw (0,0) node[anchor=north east] {$x$}
      (4,0) node[anchor=north west] {$a$}  % want it near corner (4, 0)
      (0,2) node[anchor=east]{$b$}        % want it near point (0, 2)
      (4,2) node[anchor=west]{$c$};        % want it near point (4, 2)

enter image description here

The same result can be obtained with the following code also

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{decorations.markings}

\begin{document}
\begin{tikzpicture}[
    middlearrow/.style 2 args={
        decoration={markings, mark=at position 0.5 with {\arrow{>}, \node[#1]{#2};}
        },
        postaction={decorate}
    },
]
\draw[middlearrow={below}{$\sigma$}]    (0,0)node[anchor=north east]{$x$} -- (2,0);
\draw[middlearrow={below}{$\sigma$}]    (4,0)node[anchor=north west]{$a$} -- (2,0);
\draw[middlearrow={above}{$\nu_{x}$}]   (0,4) -- (4,4);
\draw[middlearrow={right}{$\sigma$}]    (0,4) -- (2,0);
\draw[middlearrow={right}{$\sigma$}]    (4,4) -- (2,0);
\draw (0,0) -- (0,4) node[midway,left]{$b$};
\draw (4,0) -- (4,4) node[midway,right]{$c$};
\end{tikzpicture}
\end{document}

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.