绘制复积分的矩形轮廓

绘制复积分的矩形轮廓

我想要绘制下图:在此处输入图片描述

我尝试了以下代码:

\documentclass{article}
\usepackage{tikz}

\usetikzlibrary{decorations.markings}

\begin{document}
\begin{tikzpicture}[decoration={markings,
    mark=at position 1cm   with {\arrow[line width=1pt]{stealth}},
    mark=at position 4.5cm with {\arrow[line width=1pt]{stealth}},
    mark=at position 7cm   with {\arrow[line width=1pt]{stealth}},
    mark=at position 9.5cm with {\arrow[line width=1pt]{stealth}}
  }]
  \draw[thick, ->] (-6,0) -- (6,0) coordinate (xaxis);

  \draw[thick, ->] (0,0) -- (0,6) coordinate (yaxis);

  \node[above] at (xaxis) {$\mathrm{Re}(s)$};

  \node[right]  at (yaxis) {$\mathrm{Im}(s)$};

  \path[draw,blue, line width=0.8pt, postaction=decorate] (-4,4)
    -- node[midway, above, black] {$C_1$} (4,4)
    -- node[midway, right, black] {$C_N$}(4,0)
    -- node[midway, left, black] {$C_2$} (-4,0)
    -- node[midway, above, black] {$C_N$}(-4,4);
\end{tikzpicture}
\end{document}

我得到:

描述

我如何才能正确获得箭头的方向和 $x$ 轴上的标记?

谢谢您的帮助!!

答案1

作为一种“破解”方法来修复它......你可以使用\arrowreversed而不是\arrow

我还移动了声明节点的位置,以便更清楚地表明您可以在路径的同一位置添加多个节点。使用位置选项,您可以精确控制放置节点的位置。

\documentclass{article}
\usepackage{tikz}

\usetikzlibrary{decorations.markings}

\begin{document}
\begin{tikzpicture}[decoration={markings,
    mark=at position 1cm   with {\arrowreversed[line width=1pt]{stealth}},
    mark=at position 4.5cm with {\arrowreversed[line width=1pt]{stealth}},
    mark=at position 7cm   with {\arrowreversed[line width=1pt]{stealth}},
    mark=at position 9.5cm with {\arrowreversed[line width=1pt]{stealth}}
  }]
  \draw[thick, ->] (-6,0) -- (6,0) coordinate (xaxis);

  \draw[thick, ->] (0,0) -- (0,6) coordinate (yaxis);

  \node[above] at (xaxis) {$\mathrm{Re}(s)$};

  \node[right]  at (yaxis) {$\mathrm{Im}(s)$};

  \path[draw,blue, line width=0.8pt, postaction=decorate] 
        (-4,4)
    --  (4, 4)  node[midway, above right, black] {$C_1$} 
    --  (4, 0)  node[midway, right, black] {$C_N$} node[below, black] {$R$}
    --  (-4,0)  node[midway, below, black] {$C_2$} node[below, black] {$-R$} 
    --  (-4,4)  node[midway, left, black] {$C_N$};
\end{tikzpicture}
\end{document}

解决方案

相关内容