我想在数独表中设置预行和预列。我设法手动设置了这些(请参阅下面的文件)。但我对我的解决方案并不满意。
有一个更好的方法吗?
\documentclass[10pt]{article}
\usepackage{sudoku}
\usepackage{titlesec}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\renewcommand*\sudokuformat[1]{\sffamily#1}
\setlength\sudokusize{5cm}
\begin{sudoku}
|6|2|8|5|3|4|9|1|7|.
|5|1|9|8|7|2|4|3|6|.
|4|3|7|9|1|6|2|5|8|.
|8|6|5|2|4|7|1|9|3|.
|3|9|2|1|8|5|7|6|4|.
|7|4|1|6|9|3|5|8|2|.
|2|5|4|3|6|9|8|7|1|.
|1|7|6|4|5|8|3|2|9|.
|9|8|3|7|2|1|6|4|5|.
\end{sudoku}
\large
\vspace{-5.9cm}
\hspace{2.29cm}
$\begin{array}{cccccccccc}
%\hline
\vspace{.125cm}
&1 & 2 &8 &3 &5 &6 & 7& 4& 9 \\
\vspace{.065cm}
9& & & & & & & && \\
\vspace{.065cm}
4& & & & & & & && \\
\vspace{.065cm}
3& & & & & & & && \\
\vspace{.065cm}
8& & & & & & & && \\
\vspace{.065cm}
5& & & & & & & && \\
\vspace{.065cm}
6& & & & & & & && \\
\vspace{.065cm}
7& & & & & & & && \\
\vspace{.065cm}
2& & & & & & & && \\
\vspace{.065cm}
1& & & & & & & && \\
\end{array}$
\end{document}
答案1
您可以使用逻辑谜题( texdoc logicpuzzle
) 包。它支持各种拼图,包括一些需要“预列”的拼图,例如Skyline
!
\documentclass[10pt]{article}
\usepackage{logicpuzzle}
\let\puzzletitleformat\titleformat
\let\titleformat\relax
\usepackage{titlesec}
\begin{document}
% sffamily
\tikzset{every node/.style={font=\sffamily}}
% use scale and fontsize options to change size
\begin{lpsudoku}[scale=.5,fontsize=small]
\setrow{9}{6,2,8,5,3,4,9,1,7}
\setrow{8}{5,1,9,8,7,2,4,3,6}
\setrow{7}{4,3,7,9,1,6,2,5,8}
\setrow{6}{8,6,5,2,4,7,1,9,3}
\setrow{5}{3,9,2,1,8,5,7,6,4}
\setrow{4}{7,4,1,6,9,3,5,8,2}
\setrow{3}{2,5,4,3,6,9,8,7,1}
\setrow{2}{1,7,6,4,5,8,3,2,9}
\setrow{1}{9,8,3,7,2,1,6,4,5}
% use Skyline puzzle commands for 'pre-columns'
\skylineT{1,2,8,3,5,6,7,4,9}
\skylineL{1,2,7,6,5,8,3,4,9}
\end{lpsudoku}
\结束{文档}