1

this is my code snipped I am experimenting with:

\documentclass{article}
\usepackage{lipsum}
\usepackage{graphicx,wrapfig}

\begin{document}

% \parshape <num lines> <indent> <width> ... \parshape 12 0pt \textwidth 0pt \dimexpr0.5\textwidth+4.0\baselineskip\relax 0pt \dimexpr0.5\textwidth+3.25\baselineskip\relax 0pt \dimexpr0.5\textwidth+1.75\baselineskip\relax 0pt \dimexpr0.5\textwidth+1\baselineskip\relax 0pt \dimexpr0.5\textwidth+2.0\baselineskip\relax 0pt \dimexpr0.5\textwidth+2.75\baselineskip\relax 0pt \dimexpr0.5\textwidth+3.5\baselineskip\relax 0pt \dimexpr0.5\textwidth+4.25\baselineskip\relax 0pt \dimexpr0.5\textwidth+5.0\baselineskip\relax 0pt \dimexpr0.5\textwidth+6.75\baselineskip\relax 0pt \textwidth \noindent\lipsum[1]

\end{document}

The original code is from @Werner (Advanced Wrapfig) (all credits to him). I would like to "mirror" the shape of the text, i.e. the shape should be on the left-hand side, but I don't understand how to change the above code. Can anyone from the community help me please? Thanks in advance!

mario1000
  • 142

1 Answers1

2

Syntax: \parshape <n> <indent line 1> <text width line 1> … <indent line n> <text width line n>

So to have a shape on the left, you have to replace 0pt by the expected text indent and the second value should than be \dimexpr \textwidth - <indent of this line>\relax.

Example:

\documentclass{article}
\usepackage{lipsum}
%\usepackage{graphicx,wrapfig}% Not needed for using `\parshape`

\begin{document}

% \parshape <num lines> <indent> <width> ... \parshape 11 0pt \textwidth 1em \dimexpr\textwidth-1em\relax 2em \dimexpr\textwidth-2em\relax 3em \dimexpr\textwidth-3em\relax 4em \dimexpr\textwidth-4em\relax 5em \dimexpr\textwidth-5em\relax 4em \dimexpr\textwidth-4em\relax 3em \dimexpr\textwidth-3em\relax 2em \dimexpr\textwidth-2em\relax 1em \dimexpr\textwidth-1em\relax 0pt \textwidth \noindent\lipsum[1]

\end{document}

enter image description here

From LaTeX 2022-06-01 you can use \dimeval{…} instead of \dimexpr …\relax, and therefore a somehow more LaTeX like syntax:

\NeedsTeXFormat{LaTeX2e}[2022-06-01]
\documentclass{article}
\usepackage{lipsum}

\begin{document}

% \parshape <num lines> <indent> <width> ... \parshape 11 0pt \textwidth 1em \dimeval{\textwidth-1em} 2em \dimeval{\textwidth-2em} 3em \dimeval{\textwidth-3em} 4em \dimeval{\textwidth-4em} 5em \dimeval{\textwidth-5em} 4em \dimeval{\textwidth-4em} 3em \dimeval{\textwidth-3em} 2em \dimeval{\textwidth-2em} 1em \dimeval{\textwidth-1em} 0pt \textwidth \noindent\lipsum[1]

\end{document}

See ltnews35 and LaTeX for authors — current version section 5 for more information about \dimeval.

Note: If the LaTeX run reports \dimeval as unknown command sequence with the example above, your LaTeX installation is too old. Either update or use the \dimexpr…\relax version instead.

BTW: The last pair is not only used for line n but all lines >= n in the paragraph, if the paragraph has more than n lines.

For more information about \dimexpr…\relax see The ε-TeX manual, section 3.5.

cabohah
  • 11,455
  • Thanks a lot! Have a nice day! – mario1000 Dec 11 '23 at 09:15
  • 2
    Nowadays you can use \dimeval{\textwidth-2em}, which is simpler and more in line with the standard LaTeX syntax. – egreg Dec 11 '23 at 10:30
  • @egreg Yes, indeed. The question used \dimexpr. So IMHO keeping it for the answer, but using an easier to understand calculation could help. And it avoids comments: "This does not work, because \dimeval is undefined." ;-) Maybe I'll extend the answer later. – cabohah Dec 11 '23 at 11:28