# How to use a macro to specify number of lines in a \parshape

I would like to be able to use a macro to specify the number of lines in a given \parshape. So, instead of

\parshape 8 ...


for instance, I would like to be able to use

\newcommand*{\NumberOfLines}{8}
\parshape \NumberOfLines ...


However, this is problematic due to the space following \NumberOfLines being gobbled by the macro. I tried the usual trick I know of such as \relax and {} , \, but those don't work as those are taken as the size specification, which of course is invalid.

The MWE below works fine and produces

However, this has a hard coded number of lines:

\newcommand*{\MyParShape}{%
\parshape 8
\BodyParShape
}%


where I would prefer this to be

\newcommand*{\MyParShape}{%
\parshape \NumberOfLines
\BodyParShape
}%


## Code:

\documentclass{article}

\newcommand*{\Text}{%
\sloppy\noindent
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
Curabitur dictum
gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem.
Nulla et lectus vestibulum urna fringilla ultrices.%
}%

\newcommand*{\TitleParShape}{%
0.40\hsize 0.20\hsize
}%
\newcommand*{\BodyParShape}{%
0.35\hsize 0.30\hsize
0.30\hsize 0.40\hsize
0.25\hsize 0.50\hsize
0.20\hsize 0.60\hsize
0.15\hsize 0.70\hsize
0.10\hsize 0.80\hsize
0.05\hsize 0.90\hsize
0.00\hsize 1.00\hsize
}%

\newcommand*{\NumberOfLines}{8   }
\newcommand*{\MyParShape}{%
\parshape 8
%% ^^^^ The above works, but need to use a macro that contains number of lines.
%\parshape \NumberOfLines
\BodyParShape
}%

\begin{document}
\parshape 1
\TitleParShape
{\bfseries\centering My Title\par\smallskip}%
\MyParShape
\Text
\end{document}

• the version you show commented out with a space is the answer, so I'm not sure what other answers you want (although I added a \numexpr possibility below. – David Carlisle Nov 15 '18 at 8:06

\newcommand*{\NumberOfLines}{8 }


or

\newcommand*{\NumberOfLines}{\numexpr8\relax}


or

 \parshape\NumberOfLines\space


or

...

• Not sure what changed from yesterday, but yeah those work now! Really, I swear it did NOT work yesterday!! Thanks David. – Peter Grill Nov 15 '18 at 17:46