% lollipop-heading.tex copyright 1992 Victor Eijkhout
%                     copyright 2014--2016 Vafa Khalighi
%
%
%    This program is free software: you can redistribute it and/or modify
%    it under the terms of the GNU General Public License as published by
%    the Free Software Foundation, either version 3 of the License, or
%    (at your option) any later version.
%
%    This program is distributed in the hope that it will be useful,
%    but WITHOUT ANY WARRANTY; without even the implied warranty of
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%    GNU General Public License for more details.
%
%    You should have received a copy of the GNU General Public License
%    along with this program.  If not, see <http://www.gnu.org/licenses/>.
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%% H E A D I N G S %%%%%%%%%%%%
\@GenericConstruct{Heading}

\newif\if@headed
\add@generic@default{\add@after@command{\@headedno}}
\add@Heading@default{\add@after@command{\@headedyes}}

\add@Heading@default{\def\@afterpenalty{\penalty\@M}
    \default@break@afterno}
\add@Heading@default{\has@marksyes}

\def\@DefineHeading{
    \@DefineStopCommand{\relax}
    \csarg\edef{\@name}%
       {\@gen@open % this contains: \let\CSname{\@name Title}\nxp\tmp@title
        \the\@main@options@list
        \@gen@close}
    }

\@HeadingOption{TwoLines}{\switch {\if\EqualString{#1}}
    {yes} {\add@after@command{\next@paragraph{\clubpenalty\M@
                \next@paragraph{\global\clubpenalty\default@clubpenalty}}}}
    {no}  {\add@after@command{\clubpenalty\default@clubpenalty}}
    {default} {\edef\cs@e{\nxp\add@after@command{\nxp\next@paragraph
                {\clubpenalty\@w@w{#1}\relax\nxp\next@paragraph
                            	{\global\clubpenalty\default@clubpenalty}}}}
            \cs@e}
    \endswitch}

\endinput