评论

评论

我有以下代码。不知何故,我无法给整个图形编号。我尝试使用标签,但它根本不显示标签。

\begin{figure}
\centering

\subfigure[Single Crossing]{\resizebox{0.4\textwidth}{!}{ %
\begin{tikzpicture}[scale=1.5]
\draw (0,0) -- +(4,0) node[pos=0,left]{\tt\color{black}1};

\draw (0,-4)-- +(4,0) node[pos=0,left]{\tt\color{black}0};

\draw [red,line width=2pt, name path= F] (0,-4) -- (0.5,-4) to [out=20, in=195] (3.5,0)--(4,0);
\draw [blue, line width=2pt, name path= G] (0,-4) -- (1,-4) to [out=20, in=195] (3,0) -- (4,0);

\fill[gray,name intersections={of=F and G,total=\t}]
\foreach \s in {1,...,\t}{(intersection-2) node[left] {E}};

 \draw [fill] (0,-1.5) circle[radius=0.03];

 \draw [dashed,lightgray] (0,-1.5) node[left,black]{$p$} -- (2.12,-1.5) -- (2.12,-4);

 \draw [dashed,thick,gray] (2.12,-4) -- (2.12, -1)-- (0,-1)node(yline)[left,black]   {$p^{\prime}$};

 \draw [fill] (0,-1) circle [radius=0.03];

 \draw [fill=gray] (intersection-2) circle [radius=0.03];

\end{tikzpicture}

答案1

评论

我将您的代码扩展为最小工作示例(MWE)。此外,我还为该图添加了一些标题。此外,我们使用了sufigure较新且受欢迎的软件包来代替已弃用的软件包。subcaption

执行

\documentclass{article}
\pagestyle{empty} %for cropping
\usepackage{tikz,subcaption}
\usetikzlibrary{intersections}
\begin{document}
\begin{figure}
  \centering
  \begin{subfigure}{0.8\linewidth}
    \centering
    \resizebox{0.4\textwidth}{!}{
      \begin{tikzpicture}[scale=1.5]
        \draw (0,0) -- +(4,0) node[pos=0,left]{\tt\color{black}1};
        \draw (0,-4)-- +(4,0) node[pos=0,left]{\tt\color{black}0};
        \draw [red,line width=2pt, name path= F] (0,-4) -- (0.5,-4) to [out=20, in=195] (3.5,0)--(4,0);
        \draw [blue, line width=2pt, name path= G] (0,-4) -- (1,-4) to [out=20, in=195] (3,0) -- (4,0);
        \fill[gray,name intersections={of=F and G,total=\t}]
        \foreach \s in {1,...,\t}{(intersection-2) node[left] {E}};
        \draw [fill] (0,-1.5) circle[radius=0.03];
        \draw [dashed,lightgray] (0,-1.5) node[left,black]{$p$} -- (2.12,-1.5) -- (2.12,-4);
        \draw [dashed,thick,gray] (2.12,-4) -- (2.12, -1)-- (0,-1)node(yline)[left,black]   {$p^{\prime}$};
        \draw [fill] (0,-1) circle [radius=0.03];
        \draw [fill=gray] (intersection-2) circle [radius=0.03];
      \end{tikzpicture}
    }
    \caption{Single Crossing}
  \end{subfigure}
  \caption{Overall caption}
  \label{fig:somefigure}
\end{figure}
\end{document}

输出

在此处输入图片描述

相关内容