绘制 CrossFind 拼图

绘制 CrossFind 拼图

我有这个代码:

\begin{table}
\begin{tabular}{|l|l|l|l|l|l|l|l|}
\hline
A & R & R & A & N & G & E & V \\ \hline
C & A & N & C & E & L & M & O \\ \hline
H & B & Y & H & A & V & E & D \\ \hline
A & O & E & E & I & G & P & I \\ \hline
N & O & S & C & L & F & N & T \\ \hline
G & K & T & K & P & E & L & A \\ \hline
E & R & O & O & C & T & K & L \\ \hline
T & M & F & A & E & S & R & K \\ \hline
\end{tabular}
\end{table}

我想画出这个谜题的答案。我该怎么做?例如,“arrange”和“cancel”都是这个谜题的答案。谢谢

答案1

TikZ 解决方案:)

代码

\documentclass[border=5pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{matrix,backgrounds}

\begin{document}

\begin{tikzpicture}
  \matrix(m)[
    matrix of nodes,
    every node/.append style={minimum size=5ex},
  ]{
    A & R & R & A & N & G & E & V \\
    C & A & N & C & E & L & M & O \\
    H & B & Y & H & A & V & E & D \\
    A & O & E & E & I & G & P & I \\
    N & O & S & C & L & F & N & T \\
    G & K & T & K & P & E & L & A \\
    E & R & O & O & C & T & K & L \\
    T & M & F & A & E & S & R & K \\
  };
  \begin{scope}[on background layer]
    \draw[rounded corners,red,fill=red!20](m-1-1.north west)rectangle(m-1-7.south east);
  \end{scope}
\end{tikzpicture}
\end{document}

输出

在此处输入图片描述


更新

根据OP的回答,我定义了以下宏:

\newcommand\highlight[3][blue!50]{
  \fill[#1](m-#2.north west)rectangle(m-#3.south east);
}

可用于突出显示解决方案。它需要 3 个参数

  1. 第一个可选参数设置突出显示颜色(默认为 50% 蓝色与 50% 白色混合)
  2. i第二个参数给出行列处起始单元格的位置j,格式为i-j
  3. 第三个参数给出了结束单元格的位置(请注意,结束单元格应始终位于开始单元格的右侧或下方)

代码

\begin{tikzpicture}
  \matrix(m)[
    matrix of nodes,
    every node/.append style={draw,minimum size=5ex},
  ]{
    A & R & R & A & N & G & E & V \\
    C & A & N & C & E & L & M & O \\
    H & B & Y & H & A & V & E & D \\
    A & O & E & E & I & G & P & I \\
    N & O & S & C & L & F & N & T \\
    G & K & T & K & P & E & L & A \\
    E & R & O & O & C & T & K & L \\
    T & M & F & A & E & S & R & K \\
  };

  \begin{scope}[on background layer]
    \highlight[red!20]{1-1}{1-7}
    \highlight[purple!20]{2-1}{2-6}
    \highlight{6-1}{8-1}
    \highlight[yellow]{5-8}{8-8}
  \end{scope}
\end{tikzpicture}

输出

在此处输入图片描述

答案2

你可以更好地\cellcolor使用\colorbox

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{graphicx}
\definecolor{mycolor}{rgb}{0,0,10}
\newcommand{\mycell}[1]{\cellcolor{mycolor!30}{#1}}
\begin{document}
\textbf{\underline{VOCABULARY}} collocations
\textbf{1A Find six more verbs in the word square.}
\begin{table}[!h]
    \centering
    \begin{tabular}{|l|l|l|l|l|l|l|l|}
    \hline
    \mycell{A} & \mycell{R} & \mycell{R} & \mycell{A} & \mycell{N} & \mycell{G} & \mycell{E} & V \\ \hline
    \mycell{C} & \mycell{A} & \mycell{N} & \mycell{C} & \mycell{E} & \mycell{L} & M & O \\ \hline
    H & \mycell{B} & Y & \mycell{H} & \mycell{A} & \mycell{V} & \mycell{E} & D \\ \hline
    A & \mycell{O} & E & \mycell{E} & I & G & P & I \\ \hline
    N & \mycell{O} & S & \mycell{C} & L & F & N & \mycell{T} \\ \hline
    \mycell{G} & \mycell{K} & T & \mycell{K} & P & E & L & \mycell{A} \\ \hline
    \mycell{E} & R & O & O & C & T & K & \mycell{L} \\ \hline
    \mycell{T} & M & F & A & E & S & R & \mycell{K} \\ \hline
    \end{tabular}
\end{table}
\end{document}

在此处输入图片描述

更改\definecolor{mycolor}{rgb}{0,0,10}\definecolor{mycolor}{rgb}{256,256,256}仅给出没有答案的谜题:

在此处输入图片描述

答案3

没关系,我找到了一种简单的方法,尽管它不是常用的方法。以下是代码:

\usepackage{xcolor}
\usepackage{graphicx}

\begin{document}
\textbf{\underline{VOCABULARY}} collocations
\textbf{1A Find six more verbs in the word square.} 
\begin{table}[!h]
    \centering
    \begin{tabular}{|l|l|l|l|l|l|l|l|}
    \hline
    \colorbox{blue!30}{A} & \colorbox{blue!30}{R} & \colorbox{blue!30}{R} & \colorbox{blue!30}{A} & \colorbox{blue!30}{N} & \colorbox{blue!30}{G} & \colorbox{blue!30}{E} & V \\ \hline
    \colorbox{blue!30}{C} & \colorbox{blue!30}{A} & \colorbox{blue!30}{N} & \colorbox{blue!30}{C} & \colorbox{blue!30}{E} & \colorbox{blue!30}{L} & M & O \\ \hline
    H & \colorbox{blue!30}{B} & Y & \colorbox{blue!30}{H} & \colorbox{blue!30}{A} & \colorbox{blue!30}{V} & \colorbox{blue!30}{E} & D \\ \hline
    A & \colorbox{blue!30}{O} & E & \colorbox{blue!30}{E} & I & G & P & I \\ \hline
    N & \colorbox{blue!30}{O} & S & \colorbox{blue!30}{C} & L & F & N & \colorbox{blue!30}{T} \\ \hline
    \colorbox{blue!30}{G} & \colorbox{blue!30}{K} & T & \colorbox{blue!30}{K} & P & E & L & \colorbox{blue!30}{A} \\ \hline
    \colorbox{blue!30}{E} & R & O & O & C & T & K & \colorbox{blue!30}{L} \\ \hline
    \colorbox{blue!30}{T} & M & F & A & E & S & R & \colorbox{blue!30}{K} \\ \hline
    \end{tabular}
\end{table}
\end{document}

抱歉,但我不知道这个谜题的英文翻译到底是什么,谷歌翻译告诉我是:crossfind 或 crossesearch,但西班牙语是 Sopa De Letras(英文单词汤)。谢谢

交叉查找拼图

答案4

新版本,在允许使用颜色的信息之后。水平单词用黄色书写,垂直单词用蓝色书写,左右两侧的字母用绿色书写。行为可通过开关\solutionfalse/进行更改\solutiontrue

\documentclass{article} 
\usepackage{color}
\begin{document}

\newif\ifsolution
\solutionfalse

\def\0#1{\ifsolution{}\else{#1}\fi} 
\def\1#1{\ifsolution\textbf{\color{yellow}#1}\else{#1}\fi} %horizontal
\def\2#1{\ifsolution\textbf{\color{blue}#1}\else{#1}\fi} % vertical
\def\3#1{\ifsolution\textbf{\color{green}#1}\else{#1}\fi} % both

\begin{tabular}{|l|l|l|l|l|l|l|l|}
\hline
\1A &\1R & \1R & \1A & \1N & \1G &\1 E &\0 V \\ \hline
\3C & \1A & \1N & \3C &\1 E & \1L &\0 M & \0O \\ \hline
\2H &\2 B & \2Y &\3 H & \1A & \1V &\1 E & \0D \\ \hline
\2A &\2 O & \2E &\2 E &\0 I \2& \0G \2& \0P &\0 I \\ \hline
\2N & \2O &\2 S &\2 C &\0 L & \0F & \0N &\2 T \\ \hline
\2G & \2K & \0T &\2 K &\0 P & \0E & \0L & \2A \\ \hline
\2E & \0R &\0 O &\0 O &\0C &\0 T & \0K &\2 L \\ \hline
\0T & \0M &\0 F & \0A & \0E &\0 S &\0 R & \2K \\ \hline
\end{tabular}

\solutiontrue

\bigskip

\begin{tabular}{|l|l|l|l|l|l|l|l|}
\hline
\1A &\1R & \1R & \1A & \1N & \1G &\1 E &\0 V \\ \hline
\3C & \1A & \1N & \3C &\1 E & \1L &\0 M & \0O \\ \hline
\2H &\2 B & \2Y &\3 H & \1A & \1V &\1 E & \0D \\ \hline
\2A &\2 O & \2E &\2 E &\0 I \2& \0G \2& \0P &\0 I \\ \hline
\2N & \2O &\2 S &\2 C &\0 L & \0F & \0N &\2 T \\ \hline
\2G & \2K & \0T &\2 K &\0 P & \0E & \0L & \2A \\ \hline
\2E & \0R &\0 O &\0 O &\0C &\0 T & \0K &\2 L \\ \hline
\0T & \0M &\0 F & \0A & \0E &\0 S &\0 R & \2K \\ \hline
\end{tabular}

\end{document}

在此处输入图片描述

相关内容