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.

13
  • 2
    Maybe add the directive \raggedright, or \RaggedRight to allow hyphenation (requires loading ragged2e). Commented Aug 24, 2017 at 1: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.) Commented Aug 24, 2017 at 2:05
  • 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. Commented Aug 24, 2017 at 2:45
  • 2
    Are you sure you don't just need a centered title? Commented Aug 24, 2017 at 4: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. Commented Aug 24, 2017 at 4:14

2 Answers 2

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
  • 4
    If you post a small, but working, example, you will get more votes than if you post a code fragment. Commented Aug 24, 2017 at 13:54
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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.