为棋盘图片添加坐标

为棋盘图片添加坐标

我创建了一个国际象棋棋盘的图片(实际上是日本象棋),我想在棋盘上方添加阿拉伯数字(1、2、...、9)坐标,在右侧添加汉字数字。所以我的问题是:

  1. 我怎样才能在板子的顶部和侧面添加数字?

  2. 我怎样才能使用乳胶书写汉字数字?

最终结果应该是这样的:

在此处输入图片描述

这是我的代码:

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage[a3paper,nohead,nofoot]{geometry}
\usepackage{etoolbox}

\begin{document}
    \thispagestyle{empty}
    \begin{tikzpicture}[remember picture, overlay, very thick]
        \foreach \w / \h / \r in {1.5 / 1.8 / 6pt} {
            \draw [line width=5pt] (current page.center)
            +(-9 * \w, -9 * \h) -- +(-9 * \w, 9 * \h) --
            +(9 * \w, 9 * \h) -- +(9 * \w, -9 * \h) -- cycle;
            \foreach \s in {-7,-5,-3,-1,1,3,5,7} {
                \draw (current page.center) +(\s * \w, -9 * \h) -- +(\s * \w, 9 * \h);
                \draw (current page.center) +(-9 * \w, \s * \h) -- +(9 * \w, \s * \h);
            }
            
            \foreach \y in {-3, 3}
            \foreach \x in {-3, 3} {
                \fill (current page.center) +(\x * \w, \y * \h) circle [radius=\r];
            }
        }
    \end{tikzpicture}
\end{document}

编辑:谢谢 Nickie。我已将您的代码添加到我的代码中,但侧边字母未显示。这是我的新代码:

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage[a3paper,nohead,nofoot]{geometry}
\usepackage{etoolbox}

\begin{document}
    \thispagestyle{empty}
    \begin{tikzpicture}[remember picture, overlay, very thick]
        \foreach \w / \h / \r in {1.5 / 1.8 / 6pt} {
            \draw [line width=5pt] (current page.center)
            +(-9 * \w, -9 * \h) -- +(-9 * \w, 9 * \h) --
            +(9 * \w, 9 * \h) -- +(9 * \w, -9 * \h) -- cycle;
            \foreach \s in {-7,-5,-3,-1,1,3,5,7} {
                \draw (current page.center) +(\s * \w, -9 * \h) -- +(\s * \w, 9 * \h);
                \draw (current page.center) +(-9 * \w, \s * \h) -- +(9 * \w, \s * \h);
            }
            
         \foreach \i / \c in {-8/9,-6/8,-4/7,-2/6,0/5,2/4,4/3,6/2,8/1} {
            \path (current page.center) +(\i * \w, 10 * \h) node {\Huge\c};
        }
        \foreach \i / \c in {-8/a,-6/b,-4/c,-2/d,0/e,2/f,4/g,6/h,8/i} {
            \path (current page.center) +(10 * \w, \i * \h) node {\Huge\c};
        }
        }
    
    \end{tikzpicture}
\end{document}

答案1

  1. \foreach通过在外部循环主体末尾添加这两个循环:
    \foreach \i / \c in {-8/9,-6/8,-4/7,-2/6,0/5,2/4,4/3,6/2,8/1} {
      \path (current page.center) +(\i * \w, 10 * \h) node {\Huge\c};
    }
    \foreach \i / \c in {-8/a,-6/b,-4/c,-2/d,0/e,2/f,4/g,6/h,8/i} {
      \path (current page.center) +(10 * \w, \i * \h) node {\Huge\c};
    }

你会得到类似这样的结果:

结果

  1. 要获取汉字数字,请用它们(以 UTF 格式)替换字母a-并使用可以显示它们的字体(或您选择的格式)。ixelatex

相关内容