8

I'm typesetting a book using memoir in XeLaTeX, but on some pages, as an accent, I would like to make an angled margin, something like this:

enter image description here

Even if I have to define the page limit separately for each line or something, is this possible with XeLaTeX and Memoir?

I'm sorry, I would include a MWE but I really don't know where to start.

10

If you're patient enough:

enter image description here

The code:

\documentclass{memoir}
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage{lipsum}

\setmainlanguage{latin}
\nonzeroparskip

\begin{document}

\parshape
  12 
  6cm \dimexpr\textwidth-6cm\relax
  5.75cm \dimexpr\textwidth-5.75cm\relax
  5.5cm \dimexpr\textwidth-5.5cm\relax
  5.25cm \dimexpr\textwidth-5.25cm\relax
  5cm \dimexpr\textwidth-5cm\relax
  4.75cm \dimexpr\textwidth-4.75cm\relax
  4.5cm \dimexpr\textwidth-4.5cm\relax
  4.25cm \dimexpr\textwidth-4.25cm\relax
  4cm \dimexpr\textwidth-4cm\relax
  3.75cm \dimexpr\textwidth-3.75cm\relax
  3.5cm \dimexpr\textwidth-3.5cm\relax
  3.25cm \dimexpr\textwidth-3.25cm\relax
\lipsum[2]
\parshape
  8 
  3cm \dimexpr\textwidth-3cm\relax
  2.75cm \dimexpr\textwidth-2.75cm\relax
  2.5cm \dimexpr\textwidth-2.5cm\relax
  2.25cm \dimexpr\textwidth-2.25cm\relax
  2cm \dimexpr\textwidth-2cm\relax
  1.75cm \dimexpr\textwidth-1.75cm\relax
  1.5cm \dimexpr\textwidth-1.5cm\relax
  1.25cm \dimexpr\textwidth-1.25cm\relax
\lipsum[4]

\end{document}
  • 1
    well, you could re-define \par so that it's actually \\\hspace*{\parindent}, and then you could do that page-by-page. Note also that the line-breaking algorithm slows down with this. – yo' Mar 6 '15 at 18:23
2

This isn't an answer to my question, it's in response to Gonzalo Medina when he says "if you're patient enough"

I do not have the patience, but I do have python.

from __future__ import division

margin = -.25
step = .07

def paragraph(lines,margin,step,name):
    print "\\newcommand{\paragraph%s}{" %(name)
    print " \parshape"
    print " ",lines
    for lines in range(0,lines):
        print " %sin\dimexpr\\textwidth-%sin\\relax" %(margin, margin)
        margin = margin+step
    print "}"
    print ""
    return margin + (.75*step)

margin = paragraph(1,margin,step,"click")
margin = paragraph(5,margin,step,"one")
margin = paragraph(7,margin,step,"two")
margin = paragraph(4,margin,step,"three")
margin = paragraph(3,margin,step,"four")
margin = paragraph(3,margin,step,"five")

This script calculates a straight angled margin, starting with the "margin" and then stepping each line in by "step."

This script generates the parshape code, as commands, to automatically calculate across paragraphs and stuff. It outputs:

\newcommand{\paragraphclick}{
    \parshape
    1
    -0.25in\dimexpr\textwidth--0.25in\relax
}

\newcommand{\paragraphone}{
    \parshape
    5
    -0.1275in\dimexpr\textwidth--0.1275in\relax
    -0.0575in\dimexpr\textwidth--0.0575in\relax
    0.0125in\dimexpr\textwidth-0.0125in\relax
    0.0825in\dimexpr\textwidth-0.0825in\relax
    0.1525in\dimexpr\textwidth-0.1525in\relax
}

\newcommand{\paragraphtwo}{
    \parshape
    7
    0.275in\dimexpr\textwidth-0.275in\relax
    0.345in\dimexpr\textwidth-0.345in\relax
    0.415in\dimexpr\textwidth-0.415in\relax
    0.485in\dimexpr\textwidth-0.485in\relax
    0.555in\dimexpr\textwidth-0.555in\relax
    0.625in\dimexpr\textwidth-0.625in\relax
    0.695in\dimexpr\textwidth-0.695in\relax
}

\newcommand{\paragraphthree}{
    \parshape
    4
    0.8175in\dimexpr\textwidth-0.8175in\relax
    0.8875in\dimexpr\textwidth-0.8875in\relax
    0.9575in\dimexpr\textwidth-0.9575in\relax
    1.0275in\dimexpr\textwidth-1.0275in\relax
}

\newcommand{\paragraphfour}{
    \parshape
    3
    1.15in\dimexpr\textwidth-1.15in\relax
    1.22in\dimexpr\textwidth-1.22in\relax
    1.29in\dimexpr\textwidth-1.29in\relax
}

\newcommand{\paragraphfive}{
    \parshape
    3
    1.4125in\dimexpr\textwidth-1.4125in\relax
    1.4825in\dimexpr\textwidth-1.4825in\relax
    1.5525in\dimexpr\textwidth-1.5525in\relax
}

And then you can label each paragraph with the corresponding command: \paragraphone \paragraphtwo \paragraphthree or whatever you set the python script to name them.

Wish I'd written this in Lua for use with LuaLaTeX, but oh well.

It would probably only take about an hour for me to make this into a basic LuaLaTeX package...

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.