帮助复杂的平面图像

帮助复杂的平面图像

是否可以绘制下图,用 -i 和 i 替换 -1i 和 1i?谢谢!

\documentclass[landscape]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\RequirePackage[scaled]{helvet}  % Helvetica, scaled 95%
\usepackage[top=1in,bottom=1in,right=1in,left=1in]{geometry}


\DeclareMathVersion{sans}
\SetSymbolFont{operators}{sans}{OT1}{phv}{m}{n}
\SetSymbolFont{letters}{sans}{OML}{phv}{m}{it}
\SetSymbolFont{symbols}{sans}{OMS}{phv}{m}{n}
\SetMathAlphabet{\mathit}{sans}{OT1}{phv}{m}{sl}
\SetMathAlphabet{\mathbf}{sans}{OT1}{phv}{bx}{n}
\SetMathAlphabet{\mathtt}{sans}{OT1}{phv}{m}{n}
\SetSymbolFont{largesymbols}{sans}{OMX}{iwona}{m}{n}

\DeclareMathVersion{boldsans}
\SetSymbolFont{operators}{boldsans}{OT1}{phv}{b}{n}
\SetSymbolFont{letters}{boldsans}{OML}{phv}{b}{it}
\SetSymbolFont{symbols}{boldsans}{OMS}{phv}{b}{n}
\SetMathAlphabet{\mathit}{boldsans}{OT1}{phv}{b}{sl}
\SetMathAlphabet{\mathbf}{boldsans}{OT1}{phv}{bx}{n}
\SetMathAlphabet{\mathtt}{boldsans}{OT1}{phv}{b}{n}
\SetSymbolFont{largesymbols}{boldsans}{OMX}{iwona}{bx}{n}

\newif\IfInSansMode
\let\oldsf\sffamily
\renewcommand*{\sffamily}{\oldsf\mathversion{sans}\InSansModetrue}
\let\oldbf\bfseries
\renewcommand*{\bfseries}{\oldbf\IfInSansMode\mathversion{boldsans}\else\mathversion{bold}\fi\relax}
\let\oldnorm\normalfont
\renewcommand*{\normalfont}{\oldnorm\InSansModefalse\mathversion{normal}}
\let\oldrm\rmfamily
\renewcommand*{\rmfamily}{\oldrm\InSansModefalse\mathversion{normal}}

\renewcommand{\sfdefault}{phv}

\begin{document}
\sffamily \bfseries
\begin{center}
\begin{tikzpicture}
\begin{scope}[thick,font=\scriptsize]
    % Axes:
    % Are simply drawn using line with the `->` option to make them arrows:
    % The main labels of the axes can be places using `node`s:
    \draw [stealth-stealth] (-4,0) -- (4,0); %node [above left]  {$\Re\{z\}$};
    \draw [stealth-stealth] (0,-4) -- (0,4);  %node[center](i){Here $i$ Am!} %node [below right] {$\Im\{z\}$};

    %draw the parallelogram
   \draw[dashed] (0, 0)--(3,2) node[circle,fill,inner sep=1pt]{};
   \draw[dashed] (3, 2)--(2,3) node[circle,fill,inner sep=1pt]{};
   \draw[dashed] (-1, 1)--(2,3) node[circle,fill,inner sep=1pt]{};
   \draw[dashed] (0,0)--(-1,1) node[circle,fill,inner sep=1pt]{};        

   %label the parallelogram
    \draw (-1, 1) node[circle,fill,inner sep=1pt,label=left:$-1+i$]{};
    \draw (0, 0) node[circle,fill,inner sep=1pt,label=above:\hskip1.5em$0$]{};
        \draw (3, 2) node[circle,fill,inner sep=1pt,label=right:$3+2i$]{};
        \draw (2, 3) node[circle,fill,inner sep=1pt,label=right:$2+3i$]{};

    % Axes labels:
    % Are drawn using small lines and labeled with `node`s. The placement can be set using options
    \iffalse% Single
    % If you only want a single label per axis side:
    \draw (1,-3pt) -- (1,3pt)   node [above] {$1$};
    \draw (-1,-3pt) -- (-1,3pt) node [above] {$-1$};
    \draw (-3pt,1) -- (3pt,1)   node [right] {$i$};
    \draw (-3pt,-1) -- (3pt,-1) node [right] {$-i$};
    \else% Multiple
    % If you want labels at every unit step:
    \foreach \n in {-4,...,-1,1,2,...,4}{%
        \draw (\n,-4pt) -- (\n,4pt)   node [above] {$\n$};
        \draw (-4pt,\n) -- (4pt,\n)   node [right] {$\n i$};
    }
    \fi
    \end{scope}
\end{tikzpicture}
\end{center}
\end{document}

在此处输入图片描述

答案1

您可以使用\ifnum来测试是否\n1-1并调整标签:

\ifnum\n=1
    \textcolor{red}{$i$}
\else
    \ifnum\n=-1
        \textcolor{red}{$-i$}
    \else
        $\n i$
    \fi
\fi

在此处输入图片描述

笔记:

  • 添加red颜色以使变化更加明显。
  • 最好用它pgfplots来绘图而不是仅仅用来绘图tikz

代码:

\documentclass[landscape]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\RequirePackage[scaled]{helvet}  % Helvetica, scaled 95%
\usepackage[top=1in,bottom=1in,right=1in,left=1in]{geometry}


\DeclareMathVersion{sans}
\SetSymbolFont{operators}{sans}{OT1}{phv}{m}{n}
\SetSymbolFont{letters}{sans}{OML}{phv}{m}{it}
\SetSymbolFont{symbols}{sans}{OMS}{phv}{m}{n}
\SetMathAlphabet{\mathit}{sans}{OT1}{phv}{m}{sl}
\SetMathAlphabet{\mathbf}{sans}{OT1}{phv}{bx}{n}
\SetMathAlphabet{\mathtt}{sans}{OT1}{phv}{m}{n}
\SetSymbolFont{largesymbols}{sans}{OMX}{iwona}{m}{n}

\DeclareMathVersion{boldsans}
\SetSymbolFont{operators}{boldsans}{OT1}{phv}{b}{n}
\SetSymbolFont{letters}{boldsans}{OML}{phv}{b}{it}
\SetSymbolFont{symbols}{boldsans}{OMS}{phv}{b}{n}
\SetMathAlphabet{\mathit}{boldsans}{OT1}{phv}{b}{sl}
\SetMathAlphabet{\mathbf}{boldsans}{OT1}{phv}{bx}{n}
\SetMathAlphabet{\mathtt}{boldsans}{OT1}{phv}{b}{n}
\SetSymbolFont{largesymbols}{boldsans}{OMX}{iwona}{bx}{n}

\newif\IfInSansMode
\let\oldsf\sffamily
\renewcommand*{\sffamily}{\oldsf\mathversion{sans}\InSansModetrue}
\let\oldbf\bfseries
\renewcommand*{\bfseries}{\oldbf\IfInSansMode\mathversion{boldsans}\else\mathversion{bold}\fi\relax}
\let\oldnorm\normalfont
\renewcommand*{\normalfont}{\oldnorm\InSansModefalse\mathversion{normal}}
\let\oldrm\rmfamily
\renewcommand*{\rmfamily}{\oldrm\InSansModefalse\mathversion{normal}}

\renewcommand{\sfdefault}{phv}

\begin{document}
\sffamily \bfseries
\begin{center}
\begin{tikzpicture}
\begin{scope}[thick,font=\scriptsize]
    % Axes:
    % Are simply drawn using line with the `->` option to make them arrows:
    % The main labels of the axes can be places using `node`s:
    \draw [stealth-stealth] (-4,0) -- (4,0); %node [above left]  {$\Re\{z\}$};
    \draw [stealth-stealth] (0,-4) -- (0,4);  %node[center](i){Here $i$ Am!} %node [below right] {$\Im\{z\}$};

    %draw the parallelogram
   \draw[dashed] (0, 0)--(3,2) node[circle,fill,inner sep=1pt]{};
   \draw[dashed] (3, 2)--(2,3) node[circle,fill,inner sep=1pt]{};
   \draw[dashed] (-1, 1)--(2,3) node[circle,fill,inner sep=1pt]{};
   \draw[dashed] (0,0)--(-1,1) node[circle,fill,inner sep=1pt]{};        

   %label the parallelogram
    \draw (-1, 1) node[circle,fill,inner sep=1pt,label=left:$-1+i$]{};
    \draw (0, 0) node[circle,fill,inner sep=1pt,label=above:\hskip1.5em$0$]{};
        \draw (3, 2) node[circle,fill,inner sep=1pt,label=right:$3+2i$]{};
        \draw (2, 3) node[circle,fill,inner sep=1pt,label=right:$2+3i$]{};

    % Axes labels:
    % Are drawn using small lines and labeled with `node`s. The placement can be set using options
    \iffalse% Single
    % If you only want a single label per axis side:
    \draw (1,-3pt) -- (1,3pt)   node [above] {$1$};
    \draw (-1,-3pt) -- (-1,3pt) node [above] {$-1$};
    \draw (-3pt,1) -- (3pt,1)   node [right] {$i$};
    \draw (-3pt,-1) -- (3pt,-1) node [right] {$-i$};
    \else% Multiple
    % If you want labels at every unit step:
    \foreach \n in {-4,...,-1,1,2,...,4}{%
        \draw (\n,-4pt) -- (\n,4pt)   node [above] {$\n$};
        \draw (-4pt,\n) -- (4pt,\n)   node [right] {%
            \ifnum\n=1
                \textcolor{red}{$i$}
            \else
                \ifnum\n=-1
                    \textcolor{red}{$-i$}
                \else
                    $\n i$
                \fi
            \fi
            };
    }
    \fi
    \end{scope}
\end{tikzpicture}
\end{center}
\end{document}

答案2

您可以使用 pgfplots 以更简单的代码在假想平面中绘制您的问题。

%pdflatex
\documentclass[margin=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}

\begin{document}
\begin{tikzpicture}

\begin{axis}
    [
    ytick ={-7,...,8}, yticklabels={$-7i$, $-6i$, $-5i$, $-4i$, $-3i$, $-2i$, $-i$, $0$, $i$, $2i$, $3i$, $+3i$, $+4i$, $+5i$, $+6i$, $+7i$, $+8i$},
    axis lines = center,
    grid=both,
    minor tick num=1,
    ticks=both,
    xlabel=$Re(z)$,
    ylabel=$Im(z)$,
    ymin=-4,
    ymax=+5,
    xmin=-5,
    xmax=+5
    ]

    \addplot [black, mark = *] coordinates {( 0, 0)} {};
    \addplot [black, mark = *] coordinates {( 3, 2)} {};
    \addplot [black, mark = *] coordinates {( 2, 3)} {};
    \addplot [black, mark = *] coordinates {( -1, 1)} {};

    \node [below right, red] at (axis cs:  0, 0) {};
    \node [right, red] at (axis cs:  3, 2) {$3+2i$};
    \node [above, red] at (axis cs:  2, 3) {$2+3i$};
    \node [left, red] at (axis cs:  -1, 1) {$-1+i$};

    \addplot [dashed, black] coordinates { (0,0) (3,2) };
    \addplot [dashed, black] coordinates { (3,2) (2,3) };
    \addplot [dashed, black] coordinates { (2,3) (-1,1) };
    \addplot [dashed, black] coordinates { (-1,1) (0,0) };

\end{axis}
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容