如何减小字体大小来适合 Board 中的方框?

如何减小字体大小来适合 Board 中的方框?

我想画以下板\

在此处输入图片描述

但我无法减小字体大小以便数字可以适合房屋

\usepackage{chessfss}
\setlength{\parindent}{0in}
\newlength{\symsize}\setlength{\symsize}{24pt}
\newlength{\boardwidth}\setlength{\boardwidth}{8\symsize}
\setboardfontsize{\symsize}
\newcommand{\board}[1]{\setlength{\fboxsep}{0pt}%
\fbox{\parbox{\boardwidth}{\setlength{\baselineskip}{\symsize}#1}}}
\newcommand{\row}[1]{\parbox[c][\symsize]{\symsize}{\hfill{#1}}}
\newcommand{\col}[1]{\parbox[b]{\symsize}{\hfil{#1}}}
\newcommand{\chessboard}[1]{\begin{tabular}{cc}
\parbox{\symsize}{\setlength{\baselineskip}{\symsize}
\row{8} \row{7} \row{6} \row{5} \row{4} \row{3} \row{2} \row{1}}&\board{#1}\\
\row{ } &\mbox{\col{1}\col{2}\col{3}\col{4}\col{5}\col{6}\col{7}\col{8}}
\end{tabular}}
\newcommand{\TextOnWhite}[1]{\WhiteEmptySquare\hspace{-\symsize}%
\raisebox{.40\symsize}{\makebox[\symsize][c]{\small #1}}}
\newcommand{\TextOnBlack}[1]{\BlackEmptySquare\hspace{-\symsize}%
\raisebox{.40\symsize}{\makebox[\symsize][c]{\small #1}}}
\begin{document}
\large
\begin{center}\chessboard{
\TextOnWhite{}\TextOnBlack{$2008^{2}-2007$}\TextOnWhite{}\TextOnBlack{}%
\TextOnWhite{}\TextOnBlack{}\TextOnWhite{}\TextOnBlack{}\\
\TextOnBlack{}\TextOnWhite{2}\TextOnBlack{$2008^{2}-2006$}\TextOnWhite{}%
\TextOnBlack{}\TextOnWhite{}\TextOnBlack{}\TextOnWhite{}\\
\TextOnWhite{}\TextOnBlack{}\TextOnWhite{3}\TextOnBlack{$2008^{2}-2005$}%
\TextOnWhite{}\TextOnBlack{}\TextOnWhite{}\TextOnBlack{}\\
\TextOnBlack{}\TextOnWhite{}\TextOnBlack{}\TextOnWhite{$\ddots$}%
\TextOnBlack{$\ddots$}\TextOnWhite{}\TextOnBlack{}\TextOnWhite{}\\
\TextOnWhite{}\TextOnBlack{}\TextOnWhite{}\TextOnBlack{}%
\TextOnWhite{\ddots}\TextOnBlack{}\TextOnWhite{}\TextOnBlack{}\\
\TextOnBlack{}\TextOnWhite{}\TextOnBlack{}\TextOnWhite{}%
\TextOnBlack{}\TextOnWhite{2006}\TextOnBlack{$\vdots$}\TextOnWhite{$\vdots$}\\
\TextOnWhite{}\TextOnBlack{}\TextOnWhite{}\TextOnBlack{}%
\TextOnWhite{}\TextOnBlack{}\TextOnWhite{2007}\TextOnBlack{$2008^{2}-1$}\\
\TextOnBlack{$2008^{2}$}\TextOnWhite{}\TextOnBlack{}\TextOnWhite{}%
\TextOnBlack{}\TextOnWhite{}\TextOnBlack{}\TextOnWhite{2008}
}\end{center}
\end{document}

在此处输入图片描述

答案1

8x8 网格

以下是使用以下方法设置网格的方法logicpuzzle

\documentclass[tikz, border=10pt]{standalone}
\usepackage{logicpuzzle}

\begin{document}
  \centering
  \logicpuzzlesetup{%
    rows=8,
    columns=8,
    fontsize=normalsize,
    bgcolor=green!20,
    color=blue!20,
  }%
  \tikzset{
    align=center,
  }%
  \begin{logicpuzzle}
    \setnormallinewidth{.5pt}
    \setthicklinewidth{2.5pt}
    \foreach \i in {1,3,...,7}
      \fillrow{\i}{1,0,1,0,1,0,1,0};
    \foreach \i in {2,4,...,8}
      \fillrow{\i}{0,1,0,1,0,1,0,1};
    \foreach \i/\j/\k in {1/8/1,2/7/2,3/6/3,4/5/\ddots,5/4/\ddots,6/3/2006,7/2/2007,8/1/2008,1/1/2008^2,5/5/\ddots,7/3/\vdots,8/3/\vdots}
      \setcell{\i}{\j}{$\k$};
    \foreach \i/\j/\k/\l in {2/8/2008^2/-2007,3/7/2008^2/-2006,4/6/2008^2/-2005,8/2/2008^2/-1}
      \setcell{\i}{\j}{$\k$\\$\l$};
    \framearea{blue!10!black!75}{\xtikzpath{1}{1}{8/8,6/8,2/8,4/8,8/1}}
  \end{logicpuzzle}
\end{document}

答案2

您可以使用\parbox并适当缩放它,如下所示:

\newcommand{\TextOnWhite}[1]{\WhiteEmptySquare\hspace{-\symsize}%
\raisebox{.40\symsize}{\makebox[\symsize][c]{\scalebox{0.5}{\parbox{\symsize}{\centering #1}}}}}
%
\newcommand{\TextOnBlack}[1]{\BlackEmptySquare\hspace{-\symsize}%
\raisebox{.40\symsize}{\makebox[\symsize][c]{\scalebox{0.5}{\parbox{\symsize}{\centering #1}}}}}

0.5适当调整\scalebox{0.5}

在此处输入图片描述

相关内容