3

I am making a puzzle that involves putting the letters of nine-letter words in 3x3 boxes, and have written the following code to get started (MWE).

\documentclass{article}
\newcommand{\letters}[9]{\resizebox{1.75em}{!}{\begin{tabular}{ccc} #1 & #2 & #3 \\ #4 & #5 & #6 \\ #7 & #8 & #9 \end{tabular}}}

\begin{document}
\Huge
\letters{V}{I}{T}{R}{I}{O}{L}{I}{C}
\letters{P}{E}{R}{I}{S}{C}{O}{P}{E}
\letters{N}{U}{M}{E}{R}{A}{T}{O}{R}
\letters{A}{C}{T}{I}{V}{A}{T}{E}{D}
\letters{G}{L}{A}{S}{S}{W}{A}{R}{E}
\letters{I}{T}{E}{R}{A}{T}{I}{O}{N}
\letters{W}{H}{O}{O}{S}{H}{I}{N}{G}
\end{document}

However, as seen in this screenshot, it appears that the cells of the table are not all the correct size, with VITRIOLIC being larger than PERISCOPE, ACTIVATED, and ITERATION, all of which are larger than NUMERATOR, GLASSWARE, and WHOOSHING.

enter image description here

How do I make all of the letters the same height?

0

4 Answers 4

2

By choosing a TABstack instead of a tabular, I can make column widths uniform across a word. I'm not sure if this is what you need, but I choose to perform the \resizebox across the complete row and not each \letters macro.

The macro \setstacktabulargap{<length>} may be used to set the gap between letters within thetabstack, and I have selected a 1em gap between adjacent letter groups. In the first two rows, the only change is the size of the \setstacktabulargap.

Note that while the OP's syntax, \letters{V}{I}{T}{R}{I}{O}{L}{I}{C}, will still work with this implementation, the invocation can be significantly simplified with no changes to the code: \letters VITRIOLIC.

I wrap it all in a macro \setrow[<width>]{} into which the various letter invocations are made.

At the request of the OP to make it compatible with tabular, I EDITED the answer to do several things:

  1. I added an optional argument to \setrow to specify the desired group width;

  2. I change the stack end-of-line delimiting character from \\ to \cr, so that tabular did not get confused (thus, the \letters definition needed revision to reflect this).

  3. I changed the vertical stacking gap [baselineskip] from the default \baselinekip to \normalbaselineskip, since the latter is not reset within a tabular environment; and

  4. I changed the \tabularLongstack to a \tabularCenterstack, so that the stack would be centered around the baseline, rather than sitting upon it.

Here is the MWE (note: I got rid of \Huge at the opening of the document):

\documentclass{article}
\usepackage{graphicx,lipsum}
\usepackage{tabstackengine}
\fixTABwidth{T}
\setstackEOL{\cr}
\setstackgap{L}{\normalbaselineskip}
\setstacktabulargap{.5em}
\newcommand{\letters}[9]{\tabularCenterstack{ccc}{#1&#2&#3\cr#4&#5&#6\cr#7&#8&#9}\hspace{1em}}
\newcommand\setrow[2][\textwidth]{\noindent\resizebox{#1}{!}{#2\hspace{-1em}}}
\begin{document}
\setrow{%
\letters VITRIOLIC
\letters PERISCOPE
\letters NUMERATOR
\letters ACTIVATED
\letters GLASSWARE
\letters ITERATION
\letters WHOOSHING}

\bigskip

\setstacktabulargap{.1em}
\setrow{%
\letters VITRIOLIC
\letters PERISCOPE
\letters NUMERATOR
\letters ACTIVATED
\letters GLASSWARE
\letters ITERATION
\letters WHOOSHING}

\bigskip

\setrow{%
\letters VITRIOLIC
\letters PERISCOPE
\letters NUMERATOR
\letters ACTIVATED
\letters GLASSWARE}

\lipsum[1]

{\centering
\begin{tabular}{|c|c|}
\hline
Game Number & Game\\
\hline
1 & \setrow[.5\textwidth]{%
\letters VITRIOLIC
\letters PERISCOPE
\letters NUMERATOR
\letters ACTIVATED
\letters GLASSWARE
}\\
\hline
2 & \setrow[.5\textwidth]{%
\letters NUMERATOR
\letters ACTIVATED
\letters GLASSWARE
\letters ITERATION
\letters WHOOSHING}\\
\hline
\end{tabular}

\end{document}

enter image description here

2
  • This is nice. I'm trying to incorporate this into a table, but am having difficulties. Could you assist me with that?
    – Arcturus
    Commented Jul 20, 2016 at 14:09
  • @Eridan Please see revision. Commented Jul 20, 2016 at 14:33
1

You can use packages stringstrings and tikz, the first one to extract the letters of the word and the second one to place them uniformly. I have added an optional argument to the command \squareword to have control over the separation between the letters. By default the separation is 1em.

The result:

enter image description here

And the code:

\documentclass{article}

\usepackage{stringstrings}
\usepackage{tikz}

\newcommand{\squareword}[2][1em]{
\begin{tikzpicture}
    \foreach \z in {1,...,9}{
        \pgfmathsetmacro{\i}{mod(\z-1,3)}
        \pgfmathsetmacro{\j}{(\i-\z+1)/3}
        \coordinate (a\z) at (#1*\i,#1*\j);}
    \foreach \y in {1,...,9}{
        \substring[q]{#2}{\y}{\y}
        \node[anchor=base] at (a\y){\thestring};}
\end{tikzpicture}
}


\begin{document}

\squareword{VITRIOLIC}
\squareword{PERISCOPE}
\squareword{NUMERATOR}
\squareword{ACTIVATED}
\squareword{GLASSWARE}
\squareword{ITERATION}
\squareword{WHOOSHING}

\Huge
\squareword{VITRIOLIC}
\squareword{PERISCOPE}
\squareword{NUMERATOR}
\squareword{ACTIVATED}
\squareword{GLASSWARE}
\squareword{ITERATION}
\squareword{WHOOSHING}

\normalsize
\squareword[1.5em]{VITRIOLIC}
\squareword[2em]{PERISCOPE}
\squareword[0.8em]{NUMERATOR}
\squareword[0.5em]{ACTIVATED}
\squareword[3mm]{GLASSWARE}
\squareword[4mm]{ITERATION}
\squareword[0.5cm]{WHOOSHING}

\end{document}
0

Klutzy, but it does the trick:

\documentclass{article}

\newcommand{\letter}[1]{{\fontsize{24}{24}\selectfont #1}}
\newcommand{\letters}[9]{\begin{tabular}{ccc} \letter{#1} & \letter{#2} & \letter{#3} \\ \letter{#4} & \letter{#5} & \letter{#6} \\ \letter{#7} & \letter{#8} & \letter{#9} \end{tabular}}

\begin{document}
\Huge
\letters{V}{I}{T}{R}{I}{O}{L}{I}{C}
\letters{P}{E}{R}{I}{S}{C}{O}{P}{E}
\letters{N}{U}{M}{E}{R}{A}{T}{O}{R}
\letters{A}{C}{T}{I}{V}{A}{T}{E}{D}
\letters{G}{L}{A}{S}{S}{W}{A}{R}{E}
\letters{I}{T}{E}{R}{A}{T}{I}{O}{N}
\letters{W}{H}{O}{O}{S}{H}{I}{N}{G}
\end{document}
4
  • This makes the tables all coincide with each other, and when the resizebox line is added back in, the problem persists.
    – Arcturus
    Commented Jul 19, 2016 at 2:59
  • Yes, the resizebox IS the problem. To make things bigger, resize the letters instead of the box containing them.
    – JPi
    Commented Jul 19, 2016 at 3:09
  • Or, alternatively, make all entries of the tabular the same size using one of the phantom commands.
    – JPi
    Commented Jul 19, 2016 at 3:10
  • Adjusting the font size and baselineskip (changes to this appear to do nothing) add an excessive amount of vertical and horizontal whitespace in the table. Is there a solution that doesn't do this?
    – Arcturus
    Commented Jul 19, 2016 at 4:28
0

The widths may be different. You should resize to height.

\documentclass{article}
\usepackage{graphicx}
\newcommand{\letters}[9]{%
  \resizebox{!}{1em}{%
    \begin{tabular}{ccc}
    #1 & #2 & #3 \\
    #4 & #5 & #6 \\
    #7 & #8 & #9
    \end{tabular}%
  }%
}

\begin{document}
\Huge
\letters{V}{I}{T}{R}{I}{O}{L}{I}{C}
\letters{P}{E}{R}{I}{S}{C}{O}{P}{E}
\letters{N}{U}{M}{E}{R}{A}{T}{O}{R}
\letters{A}{C}{T}{I}{V}{A}{T}{E}{D}
\letters{G}{L}{A}{S}{S}{W}{A}{R}{E}
\letters{I}{T}{E}{R}{A}{T}{I}{O}{N}
\letters{W}{H}{O}{O}{S}{H}{I}{N}{G}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .