使用 \fill 绘制点

使用 \fill 绘制点

我对 Latex 完全陌生,我必须在我正在撰写的文章中说明一些事情。我遇到的问题是,我有一个圆圈:

\draw[thick](3,3) circle(4.25);

我正在尝试使用:

\fill [red] (canvas cs:x=4.623588cm,y=6.919691cm)  
    circle (4pt);

在其上绘制点。问题是,在某些地方你可以看到红色画布点下面的圆圈,而在其他地方你看不到。我怎样才能强制画布点始终覆盖其下方的所有内容?

以下是我所拥有的:

\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsfonts, amsmath, amssymb,}
\usepackage[none]{hyphenat}
\usepackage{fancyhdr}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pst-eucl}
\usepackage[nottoc, notlot, notlof]{tocbibind}

\usepackage{bm,nicefrac}

\begin{document}
\begin{center}
    \begin{tikzpicture}

        \fill [red] (canvas cs:x=4.623588cm,y=6.919691cm)  
        circle (4pt);

    \draw[thick](3,3) circle(4.25);

        \fill [red] (canvas cs:x=0cm,y=0cm)   circle (4pt);
        \fill (canvas cs:x=0cm,y=6cm)   circle (4pt);
        \fill (canvas cs:x=6cm,y=6cm)   circle (4pt);
        \fill (canvas cs:x=6cm,y=0cm)   circle (4pt);

        \fill [red] (canvas cs:x=3cm,y=7.24264cm)   circle (4pt);
        \fill (canvas cs:x=-1.24264cm,y=3cm)   circle (4pt);
        \fill [] (canvas cs:x=3cm,y=-1.24264cm)   circle (4pt);
        \fill (canvas cs:x=7.24264cm,y=3cm)   circle (4pt);

    \draw [thick](0,0) rectangle (6,6);

        \fill (canvas cs:x=0cm,y=6cm)   circle (4pt);
        \fill [red] (canvas cs:x=6cm,y=6cm)   circle (4pt);

        \draw[thick](3,7.24264) -- (6,6);
        \draw[thick](0,6) -- (3,7.24264);
        \draw[thick](-1.24264,3) -- (0,6);
        \draw[thick](-1.24264,3) -- (0,0);
        \draw[thick](3,-1.24264) -- (0,0);
        \draw[thick](3,-1.24264) -- (6,0);
        \draw[thick](6,0) -- (7.24264,3);
        \draw[thick](7.24264,3) -- (6,6);

        \node[thick,red] (n1) at (-.5,-.5) {\begin{huge}$A$\end{huge}};

        \node[thick] (n1) at (-.5,6.5) {\begin{huge}$E$\end{huge}};

        \node[thick,red] (n1) at (6.5,6.5) {\begin{huge}$I$\end{huge}};

        \node[thick] (n1) at (6.5,-.5) {\begin{huge}$M$\end{huge}};

         \node[thick] (n1) at (-1.9497,3) {\begin{huge}$C$\end{huge}};

        \node[thick,red] (n1) at (3,7.9497) {\begin{huge}$G$\end{huge}};

        \node[thick] (n1) at (7.9497,3) {\begin{huge}$K$\end{huge}};

        \node[thick] (n1) at (3,-1.9497) {\begin{huge}$O$\end{huge}};

    \end{tikzpicture}
\end{center}
\end {document}

答案1

正如@Andrew所预料的那样,您的代码中的问题在于,由于所有线条都在背景中,所以您以错误的顺序绘制了内容。这里有一个建议来解决这个问题并简化您的代码。

\documentclass[11pt]{article} 
\usepackage[margin=1in]{geometry} 
\usepackage{tikz} 
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{center}
 \begin{tikzpicture}
  \draw[thick](3,3) circle(4.25);
  \node[thick,draw,minimum size={2*4.25cm},regular polygon,regular polygon sides=4] at
  (3,3) (4-gon) {};
  \node[thick,draw,minimum size={2*4.25cm},regular polygon,regular polygon
  sides=8,rotate=22.5] at
  (3,3) (8-gon) {};
  \foreach \X/\Y [count=\Z] in {G/red,E/,C/,A/red,O/,M/,K/,I/}
  {\fill [\Y] (8-gon.corner \Z) circle (4pt) 
  node[anchor=180+45+\Z*45,font=\huge]{$\X$};}
  \fill [red] (3,3) +(67.5:4.25) circle (4pt);
 \end{tikzpicture}
\end{center}
\end{document}

在此处输入图片描述

如您所见,所有实心圆圈现在都位于线条的前面,只是因为它们是后来绘制的。

答案2

与 @marmot 的回答非常相似,但没有使用regular polygon小圆圈,而是使用带标签的节点:

\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
%\usepackage{amsfonts, amsmath, amssymb,}
% \usepackage[none]{hyphenat}
% \usepackage{fancyhdr}
% \usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
%\usepackage{pst-eucl}
%\usepackage[nottoc, notlot, notlof]{tocbibind}

%\usepackage{bm,nicefrac}

\begin{document}
    \begin{center}
\begin{tikzpicture}
  \draw         (0,0)   circle      (4.25);
  \draw[thick]  (-3,-3) rectangle   (3,3);
\foreach \i/\c [count=\j from 1]
                 in {I/red, G/red,   E/black, C/black,
                     A/red, O/black, M/black, K/black}
    \node (n\j) [circle=4pt, fill=\c, label=\j*45:\huge\i] at (\j*45:4.25) {};
    \foreach \i [count=\j from 1] in {2,...,8,1}
        \draw (n\j) -- (n\i);
    \node [circle=4pt, fill=red] at (1.5*45:4.25) {};
\end{tikzpicture}
    \end{center}
\end{document}

在此处输入图片描述

相关内容