I have defined a simple class
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{mycustom}[2019/03/06 My custom class]
\LoadClass{article}
\RequirePackage{setspace}
\newcommand{\summary}{
\begingroup
\setlength{\parindent}{0cm}
\onehalfspacing
}
\newcommand{\ensummary}{
\endgroup
}
\endinput
Given that I created a simple LaTeX file, defined as:
\documentclass{mycustom}
\usepackage{lipsum}
\begin{document}
\lipsum[1][1-3]
\summary
\lipsum[1][1-4]\par
\ensummary
\lipsum[1][1-3]
\end{document}
I noticed that I do not add the par inside the \summary the One and Half Spacing just don't work. I would like to know how this behavior occurs, and if there is a way to remove \par and keep the same behavior (one and half spacing inside the \summary). Any hints for improvement are very welcome.
This is the paragraph when I add \par
This is the paragraph without \par
Pay attention to the inline spacing in paragraph at the middle.


\parI get the same output. Also, why not an environment but commands? – koleygr Mar 09 '19 at 03:03newlinetells to latex that paragraph ended. – Lin Mar 09 '19 at 03:15\newlinemay in some edge cases add an extra (blank) line.\paris less susceptible to that problem, but even that, if preceded by a space, may do the same if the last line is very tight; that can be avoided by inserting\unskip\parbefore\endgroupin ghe\ensummarydefinition. But @koleygr's question, "why not an environment?", is applicable here; that automatically takes care of all these concerns. – barbara beeton Mar 09 '19 at 03:28environmentis. If is better I would gladly learn about. – Lin Mar 09 '19 at 03:29\newenvironment{sumarry}{<place here the \summary content>}{<place here the \ensumarry content>}... Forget\begingroupand\endgroupsince an environment is "grouping" its content by default.... and use like\begin{summary} <content> \end{summary}– koleygr Mar 09 '19 at 03:39