[Tex/LaTex] Document Layout Styles

grid-typesettingpackagessectioningtypography

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.

Best Answer

Here a partial solution

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

\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{baseline}%

\edef\mtf@size{\f@size} 
\edef\mtf@baselineskip{\f@baselineskip} 
\renewcommand\normalsize{%
   \@setfontsize\normalsize\mtf@size\mtf@baselineskip
   \abovedisplayskip \mtf@baselineskip
   \abovedisplayshortskip \abovedisplayskip 
   \belowdisplayshortskip \abovedisplayskip 
   \belowdisplayskip \abovedisplayskip
   \let\@listi\@listI}
\normalsize%
%%%
\newcounter{nbs}
\newlength\mttempa
\let\mtset@fontsize\set@fontsize
\def\set@fontsize#1#2#3{%
\ifdim #2 pt<\mtf@baselineskip
\mtset@fontsize{#1}{#2}{\mtf@baselineskip}%
\else
\PackageWarning{baseline}{may be the font is used with modified baseline}%
\setcounter{nbs}{0}%
\setlength{\mttempa}{#2 pt}%
\loop
\stepcounter{nbs}%
\addtolength\mttempa{-\mtf@baselineskip}%
\ifdim\mttempa>0pt 
\repeat%
\setlength{\mttempa}{\mtf@baselineskip}%
\loop
\addtocounter{nbs}{-1}%
\ifnum\value{nbs}>0
\addtolength\mttempa{\mtf@baselineskip}%
\repeat%
\mtset@fontsize{#1}{#2}{\mttempa}%
\fi}
%%%
\setlength\smallskipamount{\z@}
\setlength\medskipamount{\mtf@baselineskip}
\setlength\bigskipamount{\mtf@baselineskip}
\setlength\footnotesep{\z@}
\setlength{\skip\footins}{\mtf@baselineskip}
\setlength\floatsep    {\mtf@baselineskip}
\setlength\textfloatsep{\mtf@baselineskip}
\setlength\intextsep   {\mtf@baselineskip}
\setlength\dblfloatsep    {\mtf@baselineskip}
\setlength\dbltextfloatsep{\mtf@baselineskip}
\setlength\@fptop{\z@}
\setlength\@fpsep{\mtf@baselineskip}
\setlength\@fpbot{\z@}
\setlength\@dblfptop{\z@}
\setlength\@dblfpsep{\mtf@baselineskip}
\setlength\@dblfpbot{\z@}
\setlength\partopsep{\z@}
\def\@listi{\leftmargin\leftmargini
            \parsep \z@  \topsep \z@ \itemsep\z@}
\let\@listI\@listi
\@listi
\def\@listii {\leftmargin\leftmarginii
              \labelwidth\leftmarginii
              \advance\labelwidth-\labelsep
              \parsep \z@  \topsep \z@ \itemsep\z@}
\def\@listiii{\leftmargin\leftmarginiii
              \labelwidth\leftmarginiii
              \advance\labelwidth-\labelsep
              \parsep \z@  \topsep \z@ \itemsep\z@}
\def\@listiv {\leftmargin\leftmarginiv
              \labelwidth\leftmarginiv
              \advance\labelwidth-\labelsep}
\def\@listv  {\leftmargin\leftmarginv
              \labelwidth\leftmarginv
              \advance\labelwidth-\labelsep}
\def\@listvi {\leftmargin\leftmarginvi
              \labelwidth\leftmarginvi
              \advance\labelwidth-\labelsep}
\setlength\lineskip{\z@}
\setlength\normallineskip{\z@}
\setlength\lineskiplimit{-\maxdimen}
\setlength\parskip{\z@}
\jot=\mtf@baselineskip
\newcommand{\partlabelfnt}{\Large\bfseries}
\newcommand{\partfnt}{\huge\bfseries}
\newcommand{\secfnt}{\Large\bfseries}
\newcommand{\subsecfnt}{\large\bfseries}
\newcommand{\subsubsecfnt}{\normalsize\bfseries}
\newcommand{\paragraphfnt}{\normalsize\bfseries}
\newcommand{\subparagraphfnt}{\normalsize\bfseries}
\renewcommand\part{%
   \if@noskipsec \leavevmode \fi
   \par
   \addvspace{2\mtf@baselineskip}%
   \@afterindentfalse
   \secdef\@part\@spart}

\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >\m@ne
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    {\parindent \z@ \raggedright
     \interlinepenalty \@M
     \normalfont
     \ifnum \c@secnumdepth >\m@ne
       \partlabelfnt \partname\nobreakspace\thepart
       \par\nobreak
     \fi
     \partfnt #2%
     \markboth{}{}\par}%
    \nobreak
    \vskip \mtf@baselineskip
    \@afterheading}
\def\@spart#1{%
    {\parindent \z@ \raggedright
     \interlinepenalty \@M
     \normalfont
     \partfnt #1\par}%
     \nobreak
     \vskip \mtf@baselineskip
     \@afterheading}
\renewcommand\section{\@startsection {section}{1}{\z@}%
                                   {-\mtf@baselineskip}%
                                   {\mtf@baselineskip}%
                                   {\normalfont\secfnt}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                     {-\mtf@baselineskip}%
                                     {1sp}%
                                     {\normalfont\subsecfnt}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                     {-\mtf@baselineskip}%
                                     {-1em}%
                                     {\normalfont\subsubsecfnt}}
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                                    {-\mtf@baselineskip}%
                                    {-1em}%
                                    {\normalfont\paragraphfnt}}
\renewcommand\subparagraph{\@startsection{subparagraph}{5}{\parindent}%
                                       {-\mtf@baselineskip}%
                                       {-1em}%
                                      {\normalfont\subparagraphfnt}}
\setlength\abovecaptionskip{\mtf@baselineskip}
\setlength\belowcaptionskip{\mtf@baselineskip}
\long\def\@makecaption#1#2{%
  \vskip\abovecaptionskip
  \sbox\@tempboxa{#1: #2}%
  \ifdim \wd\@tempboxa >\hsize
    #1: #2\par
  \else
    \global \@minipagefalse
    \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
  \vskip\belowcaptionskip}
\renewcommand*\l@part[2]{%
  \ifnum \c@tocdepth >-2\relax
    \addpenalty\@secpenalty
    \setlength\@tempdima{3em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      {\leavevmode
       \large \bfseries #1\hfil \hb@xt@\@pnumwidth{\hss #2}}\par
       \nobreak
       \if@compatibility
         \global\@nobreaktrue
         \everypar{\global\@nobreakfalse\everypar{}}%
      \fi
    \endgroup
  \fi}
\renewcommand*\l@section[2]{%
  \ifnum \c@tocdepth >\z@
    \addpenalty\@secpenalty
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
    \endgroup
  \fi}
\renewcommand*\l@subsection{\@dottedtocline{2}{1.5em}{2.3em}}
\renewcommand*\l@subsubsection{\@dottedtocline{3}{3.8em}{3.2em}}
\renewcommand*\l@paragraph{\@dottedtocline{4}{7.0em}{4.1em}}
\renewcommand*\l@subparagraph{\@dottedtocline{5}{10em}{5em}}
\renewcommand\indexspace{\par \vskip\mtf@baselineskip\relax}
\renewcommand\footnoterule{%
  \hrule\@width.4\columnwidth
  \kern3.5\p@}

\endinput

MWE

\documentclass{article}

\usepackage{baseline}
%----------------------------------
%              just for the example
\newtheorem{theorem}{Theorem}[section]
\usepackage{blindtext}
%----------------------------------
%                 just for the show
\usepackage{tikz}
\usepackage{eso-pic}
\AddToShipoutPicture{%
\begin{tikzpicture}[overlay,remember picture]
  \draw[blue!20!white,thin]
       (current page.south west) grid [ystep=12pt,xstep=\paperwidth] (current page.north east);
\end{tikzpicture}}
%----------------------------------
\begin{document}
\tableofcontents
\blindmathtrue
\blindtext
\begin{center}
Lorem ipsum dolor sit amet,
\end{center}
\begin{theorem}
\blindtext
 \[\bar x = \frac{1}{n}\sum_{i=1}^{i=n} x_i = \frac{x_1 + x_2 + \dots{} + x_n}{n}\]
\end{theorem}
\Blinddocument

\end{document}

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

\documentclass{article}
\fontsize{15pt}{18pt}\selectfont
\usepackage{baseline}

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