1

My thesis office requires an inverted pyramid for all chapter titles. Here is the code I am using to produce the result:

\newcommand{\invpyr}[1]{
\vbox{
    \hsize=4.5in
    \parindent=0pt
    \emergencystretch=1in
    \parshape 6
    0.00in 4.50in
    0.25in 4.00in
    0.50in 3.50in
    0.75in 3.00in
    1.00in 2.50in
    1.25in 2.00in
    \leftskip=0pt plus 1fil
    \rightskip=0pt plus -1fil
    \parfillskip=0pt plus 2fil
    #1\par
    }
}

This successfully makes an inverted pyramid, but it also stretches the spacing between the words to "fill" each line of the pyramid. I need the spacing to be the same as the rest of the document. In other words, if the top line of the pyramid is 4.5" of available space, I might end up using 4" because the spaces between the words are a normal space.

  • 2
    Maybe add the directive \raggedright, or \RaggedRight to allow hyphenation (requires loading ragged2e). – Bernard Aug 24 '17 at 01:59
  • 1
    Add some positive stretch to \rightskip instead of plus -1fil which I'm not sure why you have. (Just remove the - sign in \rightskip, and maybe change \leftskip too if you're not happy with the results.) – ShreevatsaR Aug 24 '17 at 02:05
  • I tried messing with the fil numbers and it doesn't seem to have an effect. I should have been clear I don't know what this code does fully because I just took it from someone else asking about inverted pyramids here. – tomsrobots Aug 24 '17 at 02:16
  • I'm worried about allowing hyphenation in the titles because it might get kicked back to me. – tomsrobots Aug 24 '17 at 02:17
  • 4
    @tomsrobots Please post a full (and minimal) working example -- something starting with \documentclass and ending with \end{document}, and illustrating only the title you have and get, and describe what you want instead. – ShreevatsaR Aug 24 '17 at 02:45
  • 1
    You're sure the thesis office isn't joking? They certainly demand some wacky things, but this isn't necessarily even possible? What if you're a chemist and the title of your chapter ends with a 30-charachter chemical name? Do they require you to change the content of the thesis in that case? Because no thesis office has any right limiting what may be said - that's up to your committee, your school etc. – cfr Aug 24 '17 at 02:58
  • @ShreevatsaR A minimum working example is very difficult because I am required to use the school's .sty file that overwrites a lot of stuff and it is so long that it is hard to parse out the relevant sections. Is it not possible to temporarily override justified text when using parshape?

    To cfr: You're telling me.

    – tomsrobots Aug 24 '17 at 03:05
  • 1
    @tomsrobots Chances are, your \invpyr{my long title} will work the same (show the same stretching between words etc.) even with \documentclass{article}. So your minimal example can just use a standard document class. Alternatively, if your school's .sty file isn't secret (presumably if it's shared with all students in the school it isn't intended to be), then just keep it, upload it somewhere and link to it, remove everything else from your thesis, and that will be your MWE. – ShreevatsaR Aug 24 '17 at 03:21
  • 2
    Are you sure you don't just need a centered title? – John Kormylo Aug 24 '17 at 04:12
  • 2
    Is parshape really necessary here? Presumably you mean triangle (2D) rather than pyramid (3D)? You can use TikZ. Just draw an inverted triangle and insert the text in the shape. – Ross Aug 24 '17 at 04:14
  • 1
    If your titles are longer than two lines, you could manually add a \linebreak to force the second line to be shorter than the first. – John Kormylo Aug 24 '17 at 04:24
  • 1
    why do you have negative fill here? (but it makes little sense to use a parshape) just use \centering and use manual breaks with \\ while preferring shorter lines at the start. Titles usually benefit from manual line breaking in any case. – David Carlisle Aug 24 '17 at 06:29
  • I know people are trying to be helpful, but comments such as "Are you really, really sure this is what you need?" are not helpful. Anyone who has ever dealt with the style guide of a graduate university office knows that yes, the style guide is really that stupid and required. – Paul Sep 01 '22 at 08:58

2 Answers2

1

I didn't realize I could put in linebreaks in chapter headings while maintaining how they are displayed in the table of contents. My eventual solution looked like this:

\chapter[This is a really long title that needs to be wrapped as an inverted pyramid]{This is a really long title that \\ needs to be wrapped as an \\ inverted pyramid}
1

I have been having the same problem with the style guide from our doctoral office.

I had found the same code snippet as above and had the same problem. I finally just sat down and read through relevant sections of the TeXbook by Knuth and figured it out. See especially Exercise 14.34, solved in Appendix A. Hopefully this answer will help someone else (since I assume to OP already submitted).

Here is a modified version of the code snippet that I used, similar to above:

\newcommand\pyramidtitle[1]{%
        \vbox{%
                \hsize=5.0in
                \parindent=0pt
                \leftskip=0pt plus2em
                \rightskip=0pt plus2em
                \parfillskip=0pt
                \emergencystretch=1in
                \spaceskip=0.3333em
                \xspaceskip=.5em
                \hyphenpenalty=9999
                \exhyphenpenalty=9999
                \pretolerance=9999
                \tolerance=9999
                \parshape6
                0.00in 5.00in
                0.25in 4.50in
                0.50in 4.00in
                0.75in 3.50in
                1.00in 3.00in
                1.25in 2.50in
                \strut
                #1%
        }%
}

Here is what each thing in the above means and why I changed it.

  • \hsize=5.0in
    • This is the width of the vbox
  • \parindent=0pt
    • Don't indent
  • \leftskip=0pt plus2em
    • The original had a very large stretch amount. If you want to center, make this stretch smaller to ensure that each line is roughly as big as you want it to be
  • \rightskip=0pt plus2em
    • This was originally negative, which was required when it was "full justified".
  • \parfillskip=0pt
    • This is the amount available on the right side of the last line. It needed to be allowed to stretch by double the stretch of \leftskip or \rightskip when it was full justified. Now, want it to be zero since we are just centering
  • \emergencystretch=1in
  • \spaceskip=0.3333em and \xspaceskip=.5em
    • This is actually key. This is the interword spacing. I took these directly from the TeXbook. These are also the same as the definition in \raddedright in TeX.
  • \hyphenpenalty=9999, \exhyphenpenalty=9999, \pretolerance=9999, \tolerance=9999
    • These make sure that there is no hyphenation in the title
  • \parshape6
    • This is where you start to define the inverted pyramid. This says that you will define the shape of the paragraph using 6 pairs of numbers. The numbers must then follow
  •  0.00in 5.00in
     0.25in 4.50in
     0.50in 4.00in
     0.75in 3.50in
     1.00in 3.00in
     1.25in 2.50in
    
    • These are the six pairs of numbers. Each pair of numbers is one line of the vbox paragraph. So this definition allows for six lines.
    • The first number is how far to indent from the left of the vbox. The second number is the width of this line from its start. So each line is 0.5in shorter than the previous, and is indented by 0.25in from the line above it, which makes each line centered
  • \strut
    • This is a zero width strut. I'll be honest, I am not sure why it has to be there, but it is also in lots of examples in the TeXbook.
  • #1
    • This is where it will put the title

I actually have two of these definitions: one for the title of the paper (which occurs about 3 or four times in different places in my document) and one for the chapter titles. Chapter titles for me are only allowed to be 4 inches, so it is a smaller box. Also, my title is not allowed to be more than 4 lines. I left the above example as 6 lines since it was in the question.

The reason I did it this way instead of the OPs solution, is that I am trying to make a class and wanted it to be generic.

Paul
  • 544