0

I wrote a class file, but I found if I want to change the space between the math environment and text by the solution provided by Stefan Kottwitz, the indentation appears in front of the 'abstract'. Here is the mwe,

            \begin{filecontents}{mycls.cls}
            \NeedsTeXFormat{LaTeX2e}
            \ProvidesClass{mycls}
            \LoadClass{article}
            \newdimen\@bls
            \@bls=\baselineskip
            \renewcommand\section{\@startsection {section}{1}{\z@}%
                                   {1.2\@bls  plus .3\@bls minus .1\@bls}%
                                   {5pt\@afterindentfalse}%
                                   {\sffamily\large\bfseries\raggedright}}
            \newbox\absbox
            \def\abstract{\lrbox\absbox\minipage{\textwidth}%
            \sffamily%
            \hspace{-\fill}\section*{\normalsize\noindent Abstract}\vskip -1.5mm\relax%
            }
            \def\endabstract{\endminipage\endlrbox}

            \def\keywords#1{%
            \gdef\@keywords{\begin{minipage}{\textwidth}{\normalsize\sffamily \textbf{Keywords}}\\ \parbox[t]{\textwidth}{#1}\end{minipage}}}
            \let\@keywords\@empty

            \def\@maketitle{{\noindent\usebox\absbox\par}
            {\vspace{20pt}%
            {\noindent\normalsize\@keywords}\par}{\vskip2em\relax}}
            \end{filecontents}
            \documentclass{mycls}
            \usepackage{lipsum}
            \begin{abstract}
            \lipsum[1]
            \end{abstract}
            \keywords{Hello}
            \begin{document}
            \maketitle
            \lipsum[1]
            \begin{equation}\label{eq:test}
            a^2+b^2=c^2
            \end{equation}
            \lipsum[1]
            \end{document} 

The class and code above gives enter image description here

But if I add the code

            \expandafter\def\expandafter\normalsize\expandafter{%
                \normalsize
                \setlength\abovedisplayskip{40pt}
                \setlength\belowdisplayskip{40pt}
                \setlength\abovedisplayshortskip{40pt}
                \setlength\belowdisplayshortskip{40pt}
            }

in the class file, the output will be

enter image description here

Some space appears in front of the 'abstract' and 'keywords'.

I want to know where the space comes from and how to cancel it.

Ice0cean
  • 1,646

1 Answers1

1

{5pt\@afterindentfalse}% is wrong, that argument should be a positive or negative length. And there are lots of % missing from ends of lines so they will generate spaces in your output. every use of \normalsize as defined above will add 4 spaces.

 \expandafter\def\expandafter\normalsize\expandafter{%
                \normalsize
                \setlength\abovedisplayskip{40pt}%%one space
                \setlength\belowdisplayskip{40pt}%% one more
                \setlength\abovedisplayshortskip{40pt}%% a third
                \setlength\belowdisplayshortskip{40pt}%% a fourth
            }
David Carlisle
  • 757,742