# Drawing A CrossFind Puzzle

I've got this code:

\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}


I want to draw the solutions of this puzzle. How can I do it? For instance, "arrange" and "cancel" are both solutions of this puzzle. Thanks

• It is unclear, what are you expecting. Probably not how to write solutions that you kow. On the other hand, probably not to solve a puzzle by LaTeX? – Przemysław Scherwentke Nov 22 '13 at 21:16
• I only want ta draw a line around each solution, i.e. i want to draw the solved puzzle – Tobal Nov 22 '13 at 21:18
• What is a solution to this puzzle? What is the goal? – Sigur Nov 22 '13 at 21:25
• It's irrelevant, the goal is finding 8 english verbs. I only want to know how to mark the solutions, only that. – Tobal Nov 22 '13 at 21:35

TikZ solution :)

## Code

\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}


## Update

Based on OP's answer, I define the following macro:

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


that can be used to highlight the solutions. It takes 3 arguments

1. first optional argument sets the highlighting color (default is 50% blue mixed with 50% white)
2. second argument gives the location of the begin cell at row i column j, in the form i-j
3. third argument gives the location of the end cell (note that the end cell should always be either to the right or below the begin cell)

## Code

\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}


## Output

• @Tobal: You're welcome. I updated the answer by including a macro that will help with the highlighting, now that I see the effect you're after. – Herr K. Nov 22 '13 at 22:44
• Thanks, What happens if one of the solution was a diagonal solution? – Tobal Nov 23 '13 at 8:41
• @Tobal: In that case, I'm afraid one would have to do the highlighting manually, at least based on my solution. A \foreach loop may simplify things a bit: for example, \foreach \i/\j in {3/4,4/5} {\highlight[green]{\i-\j}{\i-\j}} would highlight the word "HI". – Herr K. Nov 23 '13 at 9:44
• @Tobal: One more example. \foreach \i/\j in {6/3,7/4,8/5} {\highlight{\i-\j}{\i-\j}} would highlight the word "TOE". As you can see, the pair of numbers i/j in {6/3,7/4,8/5} refer to cells given by row-i and column-j, which are to be highlighted. – Herr K. Nov 23 '13 at 9:59
• Ok, good, I thought if i change rectangle for diagonal it works, but not. Thanks again ;-) – Tobal Nov 23 '13 at 11:14

You can better use \cellcolor instead of \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}


Changing \definecolor{mycolor}{rgb}{0,0,10} to \definecolor{mycolor}{rgb}{256,256,256} gives only the puzzle without answer:

Never mind, I've found an easy way though it is not the usual way. Here's the code:

\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}


Sorry, but I don't know how it is the exactly translation in english of this puzzle, google translator says to me is: crossfind or crossearch, but in spanish is Sopa De Letras (Words Soup in English). Thanks

• Oh! You have no problem with such "words" as ranbook! :-) It was a probem for me how to deal with such cases. – Przemysław Scherwentke Nov 22 '13 at 22:16

A new version, after information that colors are allowed. Horizontal words are written yellow, vertical -- blue, letters from both -- green. The behaviour is changed by the switch \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}