7

I'm creating a crossword puzzle using the cwpuzzle package (http://www.gerd-neugebauer.de/software/TeX/cwpuzzle/en/).

I need the solution to be displayed in a much smaller format (say, 50% the original size).

I tried to use scalebox:

\scalebox{.5}{
\begin{Puzzle}{5}{5}%
|[][Sf]S|[][Sf]A|[][Sf]T|[][Sf]O|[][Sf]R|.
|[][Sf]A|[][Sf]R|[][Sf]E|[][Sf]P|[][Sf]O|.
|[][Sf]T|[][Sf]E|[][Sf]N|[][Sf]E|[][Sf]T|.
|[][Sf]O|[][Sf]P|[][Sf]E|[][Sf]R|[][Sf]A|.
|[][Sf]R|[][Sf]O|[][Sf]T|[][Sf]A|[][Sf]S|.
\end{Puzzle}
}

However, this does not produce the desired effect, as, instead of the puzzle, one basically sees a sequence of internal cwpuzzle options.

What is the proper way to rescale the puzzle to a smaller size?

2 Answers 2

5

See REVISION below, added after answer accepted.

You need to set the puzzle in a \vbox. Of course, then, if you wish to treat it as a horizontal object, the only way to control the width is to set the \vbox inside a minipage.

With this combination, one can, for example, place the reduced size puzzle in the upper left, as if it were an \hbox.

\documentclass{article}
\usepackage[pass,showframe]{geometry}
\usepackage{cwpuzzle,graphicx}
\begin{document}
\noindent\begin{minipage}{.7in}
\setbox0=\vbox{
\begin{Puzzle}{5}{5}%
|[][Sf]S|[][Sf]A|[][Sf]T|[][Sf]O|[][Sf]R|.
|[][Sf]A|[][Sf]R|[][Sf]E|[][Sf]P|[][Sf]O|.
|[][Sf]T|[][Sf]E|[][Sf]N|[][Sf]E|[][Sf]T|.
|[][Sf]O|[][Sf]P|[][Sf]E|[][Sf]R|[][Sf]A|.
|[][Sf]R|[][Sf]O|[][Sf]T|[][Sf]A|[][Sf]S|.
\end{Puzzle}
}
\scalebox{.5}{\copy0}
\end{minipage}
Normal text
\end{document}

enter image description here


REVISION:

egreg asks why \vbox and minipage. My initial attempts with \hbox failed and so I resorted to the \vbox approach above. However, I must have erred in my original approach. Here, an \hbox approach works:

\documentclass{article}
\usepackage[pass,showframe]{geometry}
\usepackage{cwpuzzle,graphicx}
\begin{document}
\noindent
\setbox0=\hbox{%
\begin{Puzzle}{5}{5}%
|[][Sf]S|[][Sf]A|[][Sf]T|[][Sf]O|[][Sf]R|.
|[][Sf]A|[][Sf]R|[][Sf]E|[][Sf]P|[][Sf]O|.
|[][Sf]T|[][Sf]E|[][Sf]N|[][Sf]E|[][Sf]T|.
|[][Sf]O|[][Sf]P|[][Sf]E|[][Sf]R|[][Sf]A|.
|[][Sf]R|[][Sf]O|[][Sf]T|[][Sf]A|[][Sf]S|.
\end{Puzzle}
}%
\scalebox{.5}{\copy0}
Normal text
\end{document}

enter image description here

4
  • Why \vbox and the minipage? And why 0.7in?
    – egreg
    Aug 16, 2021 at 15:22
  • @egreg. \hbox didn't typeset properly, whereas \vbox did. Aug 16, 2021 at 15:57
  • It does for me.
    – egreg
    Aug 16, 2021 at 16:00
  • @egreg Thanks. You are, of course, correct. I tried again and it worked. Must have typoed the first time. Aug 16, 2021 at 16:02
7

The standard Puzzle environment produces a centered object, because it executes \PuzzlePre and \PuzzlePost, defined as

\newcommand\PuzzlePre{%
    \par\noindent\mbox{}\hfill
}
\newcommand\PuzzlePost{%
    \hfill\null\par\noindent
}

The environment cannot be used in the argument of another command, because it relies on changing category codes.

You can exploit the \PuzzlePre and \PuzzlePost macros to define a Puzzle* environment that just produces a scalable box that you can then place at your pleasure. The leading optional argument is the scale factor (default 1 for no scaling).

\documentclass{article}
\usepackage{cwpuzzle,graphicx}

\newsavebox{\puzzlebox}

\newenvironment{Puzzle*}[3][1]
 {%
  \def\PuzzlePre{\begin{lrbox}{\puzzlebox}}%
  \def\PuzzlePost{\end{lrbox}\scalebox{#1}{\usebox{\puzzlebox}}}%
  \Puzzle{#2}{#3}%
 }
 {\endPuzzle}

\begin{document}

x\begin{Puzzle*}[0.5]{5}{5}%
|[][Sf]S|[][Sf]A|[][Sf]T|[][Sf]O|[][Sf]R|.
|[][Sf]A|[][Sf]R|[][Sf]E|[][Sf]P|[][Sf]O|.
|[][Sf]T|[][Sf]E|[][Sf]N|[][Sf]E|[][Sf]T|.
|[][Sf]O|[][Sf]P|[][Sf]E|[][Sf]R|[][Sf]A|.
|[][Sf]R|[][Sf]O|[][Sf]T|[][Sf]A|[][Sf]S|.
\end{Puzzle*}y

\end{document}

I added x and y just to show what the reference point of the box will be.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.