6

A mesostic is poem/text similar to an acrostic except the "spine word" runs down the middle. Wiki's article explains it ok.

The format was pioneered by the composer John Cage and as the years went on he added more rules and began to use it to "write through" large texts (like Walden) generating hundreds or more mesostic poems. Eventually he got some people to mostly automate the process via software.

I've created my own mesostic generator. Here is an example that it produced using Poe's The Raven with the spine word "Lenore":

       nearLy napping,  
        camE a  
      tappiNg,  
        as Of  
    gently Rapping,  
at my chambEr door.  

This can be achieved, roughly, with the following code:

\documentclass[11pt]{memoir}
\usepackage{fancyvrb}
\usepackage{DejaVuSansMono}
\begin{document}
\begin{Verbatim}[xleftmargin=-35mm,commandchars=\\\{\}]
                                      near\textbf{L}y napping, 
                                       cam\textbf{E} a 
                                     tappi\textbf{N}g, 
                                       as \textbf{O}f 
                                   gently \textbf{R}apping, 
                               at my chamb\textbf{E}r door. 
\end{Verbatim}
\end{document}

My mesostic generator is written in Lua and automatically adds enough spaces on the left to get the spine to line up down the center (plus I add the bold face stuff).

This works wonderfully for monospaced fonts. When I look through Cage's books I see he uses proportional fonts and yet still retains the formatting with the spine running perfectly down the center. I'm guessing that this was done manually by the typesetter.

So I'm wondering if anyone has any ideas about how to automatically format mesostics using proportional fonts within TeX/LaTeX?

Couple of notes:

  1. A solution in LuaLaTeX would be fine.

  2. In Cage's and my mesostics, all the letters are converted to lowercase with only the spine letters in caps. This is something that might be used to help format things?

  3. Cage's rules limit the total number of characters in a line to 90 or so (45 character limit on either side of the spine letter). I follow this in my software. In fact I change the font size automatically when the lines get long.

4
  • Can't you use a tabular with 3 columns (and no space between the columns)? Jan 19, 2019 at 21:15
  • I'm assuming that you mean the left "wing words" would be in one column on the left, the spine letter in a column in the middle, and then the right wing words in a third column on the right. And then just center the middle column and add the other columns? My concern would be that you'd lose some typesetting beauty by not having the letters on either side of the spine letter be properly and automatically spaced.
    – bfootdav
    Jan 19, 2019 at 21:21
  • It should be not so difficult to insert the kerning manually. Jan 19, 2019 at 21:31
  • I have no idea how one would automate inserting the kerning. I'm also not sure how one would go about centering one column of three on a page.
    – bfootdav
    Jan 19, 2019 at 21:42

3 Answers 3

5

Disclaimer. The code below doesn't imply in any way whatsoever that I endorse or otherwise hold in esteem any aspect of John Cage's work.


The following approach splits the input at \\, then builds lines one by one, setting an \hbox where the width of the center letter is measured; the box will then consist of

  1. a box as wide as half the linewidth minus half the center letter's width, flush right;
  2. the center letter;
  3. a box like in step 1, but flush left.
\documentclass{article}
\usepackage{environ,xparse}

\usepackage{kantlipsum} % for context

\ExplSyntaxOn
\NewEnviron{mesostic}
 {
  \par\addvspace{\topsep}
  \mesostic_build:V \BODY
  \addvspace{\topsep}
 }

\seq_new:N \l__mesostic_body_seq
\box_new:N \l__mesostic_center_box

\cs_new_protected:Nn \mesostic_build:n
 {
  \seq_set_split:Nnn \l__mesostic_body_seq { \\ } { #1 }
  \seq_map_inline:Nn \l__mesostic_body_seq
   {
    \__mesostic_line:w ##1 \q_stop
   }
 }
\cs_generate_variant:Nn \mesostic_build:n { V }

\cs_new_protected:Npn \__mesostic_line:w #1 | #2 | #3 \q_stop
 {
  \hbox_set:Nn \l__mesostic_center_box { \textbf{#2} }
  \hbox_to_wd:nn { \linewidth }
   {
    \hbox_to_wd:nn { (\linewidth-\box_wd:N \l__mesostic_center_box)/2 }
     {
      \hss #1
     }
    \textbf{#2}
    \hbox_to_wd:nn { (\linewidth-\box_wd:N \l__mesostic_center_box)/2 }
     {
      #3 \hss
     }
   }
 }
\ExplSyntaxOff

\begin{document}

\kant[1]

\begin{mesostic}
         near|L|y napping, \\
          cam|E| a         \\
        tappi|N|g,         \\
          as |O|f          \\
      gently |R|apping,    \\
  at my chamb|E|r door.
\end{mesostic}

\kant[2]

\end{document}

enter image description here

Changing the font might be implemented by making a tentative typesetting and measuring each part in order to see whether it satisfies the constraints of being contained in the line width; in case of failure, stop, change the font size and repeat.


A variant that allows for an optional argument where to state a font or a font size (or both); also a check for a trailing \\ is added. The main code has been simplified (thanks to jfbu for the idea).

\documentclass{article}
\usepackage{environ,xparse}

\usepackage{kantlipsum} % for context

\ExplSyntaxOn
\NewEnviron{mesostic}[1][]
 {
  #1
  \par\addvspace{\topsep}
  \mesostic_build:V \BODY
  \addvspace{\topsep}
 }

\seq_new:N \l__mesostic_body_seq
\cs_generate_variant:Nn \tl_if_empty:nT { x }

\cs_new_protected:Nn \mesostic_build:n
 {
  \seq_set_split:Nnn \l__mesostic_body_seq { \\ } { #1 }
  % check for a trailing \\
  \tl_if_empty:xT { \seq_item:Nn \l__mesostic_body_seq { -1 } }
   {
    \seq_pop_right:NN \l__mesostic_body_seq \l_tmpa_tl
   }
  \seq_map_inline:Nn \l__mesostic_body_seq
   {
    \__mesostic_line:w ##1 \q_stop
   }
 }
\cs_generate_variant:Nn \mesostic_build:n { V }

\cs_new_protected:Npn \__mesostic_line:w #1 | #2 | #3 \q_stop
 {
  \hbox_to_wd:nn { \linewidth }
   {
    \hss
    \hbox_to_wd:nn { 0pt } { \hss \tl_lower_case:n { #1 } }
    \textbf{\tl_upper_case:n { #2 }}
    \hbox_to_wd:nn { 0pt } { \tl_lower_case:n { #3 } \hss }
    \hss
   }
 }
\ExplSyntaxOff

\begin{document}

\kant[1]

\begin{mesostic}
         near|L|y napping, \\
          cam|E| a         \\
        tappi|N|g,         \\
          as |O|f          \\
      gently |R|apping,    \\
  at my chamb|E|r door.
\end{mesostic}

\kant[2]

\begin{mesostic}[\sffamily\footnotesize]
         NEAR|l|Y NAPPING \\
          CAM|e| A        \\
        TAPPI|n|G         \\
          AS |o|F         \\
      GENTLY |r|APPING    \\
  AT MY CHAMB|e|R DOOR    \\
\end{mesostic}

\kant[3]

\end{document}

enter image description here

5
  • Wow! Thank you very much, egreg! I've marked this as answered but I'm going to play around with it for the next few days. If any questions come up I'll ping you. This is really cool and so much more versatile than my Verbatim solution.
    – bfootdav
    Jan 19, 2019 at 22:41
  • @bfootdav Instead of doing tentative typesettings, it would be easy to add an optional argument for selecting font/size.
    – egreg
    Jan 19, 2019 at 22:45
  • The font size is handled in my mesostic generating software and works ok especially since there can only be at most 91 characters in a line. The software generates .tex files. I experimented with line lengths and chose font sizes for various line lengths. I ended up only needing two sizes anyway.
    – bfootdav
    Jan 19, 2019 at 22:50
  • everything is working extremely well, thanks! I have one question that is not from my original post. And if it can't be done/is too onerous don't worry about it because it's not that big of a deal. Your version allows me to do some interesting experimentation with various typographic features in the text including changing the font size on a per letter basis. I've noticed that the spine letters (the ones in caps) appear to be centered relative to their table box. Is it possible to have them print flush left instead? I've looked at your code and have been unable to figure it out.
    – bfootdav
    Jan 22, 2019 at 4:44
  • @bfootdav In this case, I guess that the left side of the bounding box should be at the page center.
    – egreg
    Jan 22, 2019 at 7:48
3
\documentclass{article}

\makeatletter
  \def\mesostic@end{\end{mesostic}}
\begingroup\catcode`\^^M\active
  \gdef\mesostic@aux#1|#2|#3\mesostic@aux%
     {\noindent\hfill%
      \llap{\MakeLowercase{#1}}%
      \textbf{\MakeUppercase{#2}}%
      \rlap{\MakeLowercase{#3}}%
      \hfill\hbox{}\par%
      \expandafter^^M}%
\endgroup
\newenvironment{mesostic}{\parskip0pt\relax
   \obeylines
   \begingroup\lccode`~`\^^M 
   \lowercase{\endgroup\def~##1~}{%
     \def\mesostic@tmp{##1}%
     \ifx\mesostic@tmp\mesostic@end
       \expandafter\mesostic@end
     \else
       \mesostic@aux##1\mesostic@aux
     \fi}%
  }{}
\makeatother

\begin{document}

blah blah blah

\noindent X\dotfill X

\begin{mesostic}
  near|L|y napping,
  cam|E| a
  tappi|N|g,
  as |O|f
  gently |R|apping,
  at my chamb|E|r door.
\end{mesostic}

\noindent X\dotfill X

blah blah blah

\noindent X\dotfill X

\begin{mesostic}
  NEAR|l|Y NAPPING,
  CAM|e| A
  TAPPI|n|G,
  AS |o|F
  GENTLY |r|APPING,
  AT MY CHAMB|e|R DOOR.
\end{mesostic}


\noindent X\dotfill X

blah blah blah

\end{document}

enter image description here

And using X\dotfill X\dotfill X for the extra lines for context:

enter image description here

3
  • of course the input can be kept in the indented form aligning the letters; I deliberately flushed it to the left to show freedom of input.
    – user4686
    Jan 19, 2019 at 22:55
  • I also illustrated the uppercasing, which seems to have been on OP's list.
    – user4686
    Jan 19, 2019 at 23:04
  • @user4686 I know it's been a while, but while revisiting the code I'm using for my project, I began to wonder how to make the spine letter (the uppercase bold one in the middle) to be flush left instead of centered? That would better match how John Cage originally did it. It only becomes apparent when using different fonts at different sizes but that is one of my use-cases. Thanks!
    – bfootdav
    Jun 8, 2019 at 1:50
3

enter image description here

 \documentclass{article}

\makeatletter
\let\zzfont\textbf
{\obeylines\everyeof{\noexpand}%
\gdef\zzz#1{%
\catcode`#1\active\scantokens{\def\zzzz{\gdef#1}}%
\zzzz##1^^M{\makebox[.5\textwidth][l]{\zzfont{\string#1}##1}\par}%
}}
\def\zz{\flushright\obeylines%
\let\or\zzz\@Alph{0\fi\iftrue}}%

\def\endzz{\endflushright}
\begin{document}

\begin{zz}
       nearLy napping,  
        camE a  
      tappiNg,  
        as Of  
    gently Rapping,  
at my chambEr door.  
\end{zz}

\renewcommand\zzfont[1]{\large$\mathcal{#1}$}
\begin{zz}
       nearLy napping,  
        camE a  
      tappiNg,  
        as Of  
    gently Rapping,  
at my chambEr door.  
\end{zz}


\end{document}
6
  • It looks like the letters to the right of the spine letter are also being bolded. Also, at least as I've implemented it in my software, whether to bold the spine letter is an option.
    – bfootdav
    Jan 19, 2019 at 23:29
  • @bfootdav sorry about that, just middle letter now bold and I made that font customisable so you could make it do nothing or pick a fancier font or whatever Jan 19, 2019 at 23:46
  • brilliant! But I am sure you get intro trouble as soon as you switch to a real language, like French or German. (try ÉGALITÉ e.g)
    – user4686
    Jan 20, 2019 at 8:02
  • not for "chipoter" but your central letters are not exactly centered on line...
    – user4686
    Jan 20, 2019 at 8:09
  • @jfbu I know, actually their left edge is on the center. You could define the \zzfont command to center it's argument in say an M box if that were needed, but I thought the spacing looked better this way. Jan 20, 2019 at 9:56

You must log in to answer this question.

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