1

I'm using the tikz package, and the following code:

\begin{tikzpicture}[scale=0.9]
    \node (A) at (-2.3,-3){};
    \node (B) at (-2.3,3){};
    \node (bb) at (0,3){};
    \draw[-] (B) -- (bb) node[] {};
    \draw[>=latex,<->] (A) -- (B) node[midway,left] {$D_u$};
    \node (C) at (-1,-2){};
    \node (D) at (-1,2){};
    \node (dd) at (0,2){};
    \node (cc) at (0,-2){};
    \node (aa) at (-1,-3){};
    \node (ee) at (0,-3){};
   \draw[-] (D) -- (dd) node[]{};
   \draw[-] (C) -- (cc) node[]{}; 
   \draw[-] (A) -- (aa) node[]{};
   \draw[-] (aa) -- (ee) node[]{};
   \draw[>=latex,<->] (C) -- (D) node[midway,left] {$D_i$};
   \draw[>=latex,<->] (C) -- (aa) node[midway,left]
{$e_{\text{min}}$};
\end{tikzpicture}

For some reason, the arrows and lines are too short as shown in the picture. This is my first time using the package, from what I've seen in other examples, people have proper lines and arrows, so I can't figure out what's causing this.

enter image description here

  • Just use ‘\coordinate’ instead of ‘\node’ – Black Mild Nov 18 '19 at 13:43
3

By default, a \node is an invisible rectangle that can contain text. If no text is provided, it is still a rectangle that has a minimum nonzero size. If you want your nodes to be points, use \node [coordinate].

You can also remove all the empty node[] {}; at the end of your \draw commands. Those are only needed if you want to put some text/node at the end of the line.

\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}

\begin{document}

\begin{tikzpicture}[scale=0.9]
    \node [coordinate] (A) at (-2.3,-3){};
    \node [coordinate] (B) at (-2.3,3){};
    \node (bb) at (0,3){};
    \draw[-] (B) -- (bb);
    \draw[>=latex,<->] (A) -- (B) node[midway,left] {$D_u$};
    \node [coordinate] (C) at (-1,-2){};
    \node [coordinate] (D) at (-1,2){};
    \node [coordinate] (dd) at (0,2){};
    \node [coordinate] (cc) at (0,-2){};
    \node [coordinate] (aa) at (-1,-3){};
    \node [coordinate] (ee) at (0,-3){};
   \draw[-] (D) -- (dd);
   \draw[-] (C) -- (cc); 
   \draw[-] (A) -- (aa);
   \draw[-] (aa) -- (ee);
   \draw[>=latex,<->] (C) -- (D) node[midway,left] {$D_i$};
   \draw[>=latex,<->] (C) -- (aa) node[midway,left]
{$e_{\text{min}}$};
\end{tikzpicture}

\end{document}

enter image description here

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.