10

I want to make up some handouts on sentence diagramming. For those who didn't have to diagram sentences at school, I'm talking about something like this.

enter image description here

It's basically an exploded view of the sentence, with the various parts all laid out in relation to each other. I would post some sample code for people to comment on, but I'm not even sure where to start with this. I'm putting the tikz tag on the question, but I don't even know whether tikz is the right tool for the job. Where should I start figuring this out?

(I did find this earlier post, but it doesn't really get at the branching &c. in the link above.)

  • I don't think the linguists' packages are likely to help here - none I've seen, anyway. (But I'm not a linguist.) So probably tikz or a similar content-agnostic approach is your only option. Unless someone else knows of something more specialised. The trouble is, there isn't really any pattern to the diagram as far as I can tell. Or there is, but it is an irregular and quirky one rather than a standard format. – cfr Jun 4 '14 at 1:46
  • That's the thing: there is a system, but it's clunky. – crmdgn Jun 4 '14 at 10:10
  • 1
    Suppose I wanted to write a package for this. How hard would that be (in the world of package-writing)? – crmdgn Jun 4 '14 at 11:01
  • 1
    Please see revision. – Steven B. Segletes Jun 4 '14 at 15:28
  • 3
    While it's possible that many people dislike grammar, I think a more telling reason is that this peculiarly American way of diagramming sentences isn't used in any scientific representation of language; there are better methods for representing structure (such as regular trees) and so interest in this notation for linguists is at best one of a curiosity of times past. – Alan Munn Jun 4 '14 at 16:43
11

TOTALLY REVISED ANSWER:

Macros available to use:

\startline[indent] draws the top startline, with optional indent.

\xdiv vertical line that crosses the startline, as between "puzzles" and "are" in the MWE.

\vdiv vertical line that does not cross the underline, as between "exercising" and "mind" in the MWE.

\ddiv diagonal line that does not cross the startline, as between "are" and "games" in the MWE.

\diag[mode]{diag-dimen}{diagtext}{horiz-dimen}{horiz-text} drops a diagonal that will vertically extend diagdimen\baselineskip downward, places the diag text over it, then draws a line of length horiz-dimen\baselineskip and set the horiz-text above it (by default). If the mode is set to [d], the horizontal line is dashed and the horiz-text is underset, like the word "yet" in the MWE. If the mode is [b], the diagonal is blanked out, as with the word "exercising" in the MWE.

\dropleg[mode]{dimen}{left-aligned underset} Drops a vertical strut of height dimen\baselineskip and then sets the final argument to the right of that. If mode is [d], the strut is dashed, as shown below "are" in the MWE.

\entry{dimen}{text}{aftercode} a self-contained underlined entry, such as "and" in the MWE. The text is centered and underlined by a line of length dimen\baselineskip, and the aftercode is executed at the right hand end of the underline.

\tstrut{dimen} the trianglular shape with a vertical strut above, as seen below "exercising" in the MWE. The height of the \tstrut object is determined by the number dimen, which is a multiple of \baselineskip, which should be the difference between the depths of two adjacent \diags.

\leftstep the stair-step thingie that is left-lapped.


Parameters:

\rlwd rule width; (.5pt) default.

\tlength the step height and the triangular leg length, both below "exercising" in the MWE; 1.7ex default.


In the MWE, you will note that horizontal space had to be added manually between entries. Also, to create the 2nd line, I left the \dropleg below "and" dangling, and used \vspace to shift to the lower position. The argument to \vspace (16\baselineskip) was easily ascertained, because the \droplegs before and after "and" were both of dimen=8. The \tstrut dimen of 2 is also easily ascertained, since the dimen of the "for" \diag was 6, while the dimen of "exercising" \diag was 4, the difference being 2.

To drop a \diag in the middle of a word, you have two options (both shown in the MWE):

1) split the word around the diag, like newspa\diag{2}{in}{5}{America}pers, or

2) place the word in a box of smaller width than its actual width, such as \makebox[3ex]{\textcolor{blue}{puzzles}}\diag{4.5}{crossword}{}{}.

In either case, you will generally follow the word with some \hspace.

Since I could not create a curved arc, the "Appearing" leg is done with a \dropleg with a \diag as the underset code.

\documentclass{article}
\usepackage[usestackEOL]{stackengine}
\usepackage{graphicx,xcolor}
% DASHED LINE OF SPECIFIED LENGTH
% Based on morsburg at http://tex.stackexchange.com/questions/12537/
% how-can-i-make-a-horizontal-dashed-line/12553#12553
\def\dashfill{\cleaders\hbox to .6em{\rule{1ex}{\rlwd}}\hfill}
\newcommand\dashline[1]{\hbox to #1{\dashfill\hfil}}
%%%%%
\def\rlwd{.5pt}
\def\xdiv{\smash{\rule[-.7071\baselineskip]{\rlwd}{1.5\baselineskip}}}
\def\vdiv{\smash{\rule[-.37\baselineskip]{\rlwd}{1.5\baselineskip}}}
\def\ddiv{\smash{\rotatebox{45}{%
  \rule[-.55\baselineskip]{\rlwd}{1.74\baselineskip}}}}
\newlength\tmplen
\newlength\tlength
\tlength=1.7ex\relax
\newcommand\tstrut[1]{\smash{\raisebox{-.35\baselineskip}{%
  \def\stackalignment{c}\stackon[0pt]{%
  \rotatebox{45}{\rule{\tlength}{\rlwd}}\kern-.2ex%
  \raisebox{.7071\tlength}{\rotatebox{-45}{\rule{\tlength}{\rlwd}}}%
  }{\rule{\rlwd}{\dimexpr #1\baselineskip-.7071\tlength}}}}%
}
\def\leftstep{\smash{\raisebox{\dimexpr-.3\baselineskip-\rlwd}{%
  \llap{\rule[\tlength]{\tlength}{\rlwd}\rule{\rlwd}{\tlength}%
  \rule{\tlength}{\rlwd}~~}}}%
}
\newcommand\dropleg[3][s]{\unskip\smash{%
  \stackunder[\dimexpr-\dp\strutbox-.7071pt]{%
    \if d#1%
      \raisebox{-\dp\strutbox}{\rotatebox{-90}{\dashline{#2\baselineskip}}}%
    \else%
      \rule[\dimexpr-\dp\strutbox-.7071pt-#2\baselineskip]{\rlwd}%
      {#2\baselineskip}%
    \fi}{#3}}\ignorespaces%
}
\newcommand\entry[3]{\smash{\makebox[0pt][l]{\def\stackalignment{c}%
  \stackunder[0pt]{\strut#2}{\rule{0#1\baselineskip}{\rlwd}}#3}}%
}
\newcommand\diag[5][s]{\unskip%
  \if b#1\def\dcolor{white}\else\def\dcolor{black}\fi%
  \tmplen=#2\baselineskip%
  \def\stackalignment{l}\def\useanchorwidth{F}%
  \smash{\makebox[0pt][l]{%
  \raisebox{\dimexpr-\dp\strutbox-.7071pt}{\rotatebox{-45}{%
    \stackon[0pt]{\textcolor{\dcolor}{\rule{1.414\tmplen}{\rlwd}}}{%
    \makebox[0pt][l]{\makebox[1.414\tmplen][l]{~~~~\strut#3}%
      \if d#1%
        \rotatebox{45}{%
          \smash{%
          \kern-.22\baselineskip\raisebox{-.3\baselineskip}{%
            \stackunder[0pt]{\dashline{0#4\baselineskip}}{~~\strut#5}}}%
          }%
      \else%
        \rotatebox{45}{%
          \kern-1.02\baselineskip\raisebox{.52\baselineskip}{%
          \stackon[0pt]{\rule{0#4\baselineskip}{\rlwd}}{~~\strut#5}}}%
      \fi%
    }}%
  }}}}\ignorespaces%
}
\newcommand\startline[1][0in]{\noindent\hspace{#1}%
  \rule{\dimexpr\textwidth-#1}{\rlwd}\par%
  \vspace{\dimexpr-\baselineskip-\parskip-\dp\strutbox-.7071pt}\par%
  \noindent\hspace{#1}%
}
\begin{document}
\scriptsize\startline
~
\dropleg{2}{%
\diag{5}{Appearing}{3}{
  \diag{2}{in}{6}{
    \diag{3}{most}{}{}
    newspa\diag{2}{in}{5}{America}pers
  }
}}
\hspace{1cm}
\makebox[3ex]{\textcolor{blue}{puzzles}}
\diag{4.5}{crossword}{}{}
\hspace{1.5cm}\xdiv\hspace{2cm}
\makebox[1ex]{\textcolor{red}{are}}
\dropleg[d]{8}{\entry{4}{and}{\dropleg[d]{8}{}}}
\hspace{.8cm}\ddiv\hspace{0.4cm}
\diag[d]{5}{challenging}{2.8}{yet}
\textcolor{black!50!green}{games}
\diag{5}{exciting}{}{}
\hspace{1cm}
\diag{6}{for}{7}{\tstrut{2}}
\hspace{1cm}
\diag[b]{4}{exercising}{5}{\leftstep\vdiv~mi\diag{1.5}{the}{}{}nd}

\vspace{16\baselineskip}
\startline[1in]
~\textcolor{blue}{they}
\hspace{1cm}\xdiv\hspace{1cm}
\diag{2}{}{8}{\diag{3}{literate}{}{}people\diag{3}{with}{5}{patience}}
\hspace{.6cm}
\textcolor{red}{give}
\hspace{.6cm}
\vdiv
\hspace{.6cm}
\textcolor{black!50!green}{joy}
\hspace{.6cm}
\ddiv
\hspace{.6cm}
exquisite
\end{document}

enter image description here

  • The traditional format is pretty rigid. I don't know whether adherence to tradition matters, since the whole practice is out of fashion these days, but the basic idea is to create a visual representation of how the words in the sentence relate to each other (so, e.g., the angled line between "are" and "games" means something different from the vertical line between "puzzles" and "are"). I imagine the next step is for me to catalogue all the relationships I would need to depict. – crmdgn Jun 4 '14 at 13:38
  • @crmdgn This is fantastic. I have been looking for something like this for a while to do Greek syntax layouts. I tried to make my own, but failed. Are you planning on making this a package in CTAN? – Paul Oct 21 '14 at 18:02
  • 1
    @Paul Thanks for the "like". Since my effort was focused on recreating an image provided by the OP, I don't feel I know enough on the protocols of sentence diagramming to call it a package. For one thing, what other necessary constructs are required? For another, I wouldn't know a correct from an incorrect diagram. With these limitations, I did not want to package it. But I am glad you find it useful, and would be happy to "support" what is already here, if I am able. – Steven B. Segletes Oct 21 '14 at 18:47
  • 1
    That feel when the result obtained in the answer is nicer of what the OP wanted to achieve. :D – gvgramazio May 3 '18 at 10:08

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.