I am inviting partial solutions for defining styles for document layouts. The solutions should be capable of defining the font size, leading (interline distance), and type for the running text as well as the style for sectional unit titles. Please see below for a definition of partial solution.

Particular care should be taken that the styles for the sectional unit titles integrate nicely with the style of the running text, so the running text should flow neatly around the titles, making sure the distance between any two lines of running text on any page is always a multiple of the user-defined leading.

There are some partial solutions to this question. For example, the grid package is a good starting point.

I don't have a particular application for any solution (answer) to my question: I posted the question, hoping that others may find the answers interesting. This is why I do not provide an MWE.

To make up for the lack of an MWE, I promise I'll award a 500-reputation bounty in one week for the best current solution, provided it shows some promise. I'll award another 500-reputation bounty in two weeks. (In the unlikely event that I'll have 500 reputation left after two weeks, I'll ward one more 500-reputation bounty in three weeks:-).

**Edit 3 September, 2015. The total 1000 reputation has been awarded. I can't respond to any further comments about this question. Also I won't be able to comment on any further solutions.

Partial Solution A partial solution may assume documents don't have displayed mathematical equations and other user-defined displays because displays may upset the inter-line distance. Furthermore, a partial solution may assume that all floats (figures, tables, etc.) are positioned at the top or bottom of the page.

  • 1
    I'm expectating about this subject. It will be useful to me, but I don't hace the knowledge to propose solution. It's a too good idea!
    – karloswitt
    Commented Aug 24, 2015 at 9:41
  • 2
    Hopefully, grid typesetting will progress thanks to your question. LaTeX only, or is XeLaTeX acceptable as well (say, using free fonts)? If time allows I will try to write a solution.
    – ienissei
    Commented Aug 25, 2015 at 12:15
  • by user-defined displays you mean equations, minipages, tabular...?
    – touhami
    Commented Aug 27, 2015 at 15:09
  • @MarcvanDongen No such thing as a simple solution! Commented Aug 27, 2015 at 23:18
  • 2
    Would this be a possible candidate for what you're looking for? tex.stackexchange.com/a/35093/3954 Commented Aug 28, 2015 at 13:36

1 Answer 1


Here a partial solution

Update: New solution this is (a new package baseline.sty)


   \abovedisplayskip \mtf@baselineskip
   \abovedisplayshortskip \abovedisplayskip 
   \belowdisplayshortskip \abovedisplayskip 
   \belowdisplayskip \abovedisplayskip
\ifdim #2 pt<\mtf@baselineskip
\PackageWarning{baseline}{may be the font is used with modified baseline}%
\setlength{\mttempa}{#2 pt}%
\setlength\floatsep    {\mtf@baselineskip}
\setlength\intextsep   {\mtf@baselineskip}
\setlength\dblfloatsep    {\mtf@baselineskip}
            \parsep \z@  \topsep \z@ \itemsep\z@}
\def\@listii {\leftmargin\leftmarginii
              \parsep \z@  \topsep \z@ \itemsep\z@}
              \parsep \z@  \topsep \z@ \itemsep\z@}
\def\@listiv {\leftmargin\leftmarginiv
\def\@listv  {\leftmargin\leftmarginv
\def\@listvi {\leftmargin\leftmarginvi
   \if@noskipsec \leavevmode \fi

    \ifnum \c@secnumdepth >\m@ne
    {\parindent \z@ \raggedright
     \interlinepenalty \@M
     \ifnum \c@secnumdepth >\m@ne
       \partlabelfnt \partname\nobreakspace\thepart
     \partfnt #2%
    \vskip \mtf@baselineskip
    {\parindent \z@ \raggedright
     \interlinepenalty \@M
     \partfnt #1\par}%
     \vskip \mtf@baselineskip
\renewcommand\section{\@startsection {section}{1}{\z@}%
  \sbox\@tempboxa{#1: #2}%
  \ifdim \wd\@tempboxa >\hsize
    #1: #2\par
    \global \@minipagefalse
  \ifnum \c@tocdepth >-2\relax
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
       \large \bfseries #1\hfil \hb@xt@\@pnumwidth{\hss #2}}\par
  \ifnum \c@tocdepth >\z@
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries
      \hskip -\leftskip
      #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
\renewcommand\indexspace{\par \vskip\mtf@baselineskip\relax}




%              just for the example
%                 just for the show
\begin{tikzpicture}[overlay,remember picture]
       (current page.south west) grid [ystep=12pt,xstep=\paperwidth] (current page.north east);
Lorem ipsum dolor sit amet,
 \[\bar x = \frac{1}{n}\sum_{i=1}^{i=n} x_i = \frac{x_1 + x_2 + \dots{} + x_n}{n}\]


User guide guide user interface:

1) The package uses default font size from class 10pt, 11pt, 12pt or 9pt, 14pt, 17pt if allowed, for example if extarticle is used but the user can also do


2) The package use default setting from class article for section like heading (shape, size ...) but not vertical spacing of course. If the use want to change this setting, the pacckage provides commands for this

\renewcommand{\partlabelfnt}{......}   % default {\Large\bfseries}
\renewcommand{\partfnt}{......}   % default {\huge\bfseries}
\renewcommand{\secfnt}{......}   % default {\Large\bfseries}
\renewcommand{\subsecfnt}{......}   % default {\large\bfseries}
\renewcommand{\subsubsecfnt}{......}   % default {\normalsize\bfseries}
\renewcommand{\paragraphfnt}{......}   % default {\normalsize\bfseries}
\renewcommand{\subparagraphfnt}{......}   % default {\normalsize\bfseries}

enter image description here

enter image description here

  • This may be a good start and the output looks good, but this solution does not have a particularly easy API for beginners. It would be nice if you could separate isolate the API in a separate style file and provide a key-value interface that lets the user define the style for the sectional unit headings. Ideally, the API should be monkey proof. E.g. it should only allow multiples of "standard leadings" for the (temporary) leading.
    – user10274
    Commented Aug 28, 2015 at 23:39
  • 1
    @MarcvanDongen I'll update my answer by adding a new solution. I'll back to my original idea.
    – touhami
    Commented Aug 29, 2015 at 22:48
  • 2
    @touhami I think for display things you have to intercept and add the right spacing "by hand" either by trapping the display in a box and measuring (the classic way) or by using \pdfsavepos (or wrappers such as tikzmark) to measure the vertical position after the display and adjust on the next run, or something else.... Commented Aug 31, 2015 at 20:12
  • 1
    @MarcvanDongen I didn't really mean it that way. It was a point about how you were saying it. I didn't think that you meant it to come across as you did. And I didn't mean my comment to come across as it obviously did either. So I'm sorry that you understood it that way. I'll delete it but it was intended to be a point about communication rather than content. But, sadly, my communication is clearly no good either.
    – cfr
    Commented Sep 2, 2015 at 2:48
  • 1
    I thought the idea was that the code would adjust in that case to ensure that the body text still started on a standard baseline. For example, if the definition of \subsection boxed the title, measured the height and then added some space to make it up to a multiple of \baselineskip or whatever. The title text would not necessarily be on the baseline but the requirement, as I understand it, is only for the running text to be. However, that approach would obviously fail for run-in titles. (But changing their size is dodgy anyway, I think.)
    – cfr
    Commented Sep 2, 2015 at 12:53

You must log in to answer this question.