Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have defined a custom paragraph named myparagraph to use it as a small, unnumbered headline within my document. The reason is that I like the font of the paragraph heading, which is not as bold as compared to \textbf{}.

Now I have just realized that each new use of myparagraph leaves a little bit too much vertical space, see the following picture with the gap in red:

enter image description here

I need to control this gap, either globally, or locally between these two myparagraphs (maybe use half the value which is used now, or something close, in order to save space) by redefining myparagraph somehow.

edit: If you got a different solution feel free to post it. It doesn't strictly have to be a redefinition of paragraph.

edit2: The headlines should not be part of the TOC. They are supposed to be very simple headlines on the lowest level so to say, nothing more.

The code is quite simple:

\documentclass[a4paper, 12pt, headsepline, headings=small,]{scrreprt}
\usepackage[onehalfspacing]{setspace}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathptmx}
\usepackage[a4paper,showframe]{geometry}
\geometry{left=2cm,right=5cm,top=2cm,bottom=2cm}
\usepackage[pangram]{blindtext}

\newcommand{\myparagraph}[1]{\paragraph{#1}\mbox{}\\[3pt]}

\begin{document}

\myparagraph{Test}
\Blindtext[1][1]
\myparagraph{Test}
\Blindtext[1][1]
\textbf{}
\end{document}

error log:

! Undefined control sequence.
<argument> \subparagraphnumdepth 
share|improve this question
    
Since you are using a KOMA-Script class: Why don’t you apply the specific macro \minisec? (Without testing: It may be though, the gap would be still too big for you.) –  Speravir Jan 10 at 22:24
    
@Speravir thanks for the hint. I tried it and the font seems to be the same as in paragraph which is good. The distance is also smaller which is even better. However I'd really like to set the distance to specific values, which might differ between cases. –  TomM Jan 10 at 22:33
1  
Sans serif fonts are the default for every title level in KOMA-Script. What I’ve forgotten to mention: Minisecs aren’t by default thought to be listed in the table of contents (could be overruled with \addtocontents or \addcontentsline). –  Speravir Jan 10 at 22:41
    
@Speravir That's fine in my case as I don't want these headlines to be in the TOC :) They are supposed to be simple headlines on the lowest level. I will edit this in the description. –  TomM Jan 10 at 22:52
2  
@TomM Update your Koma-Script suite. –  egreg Jan 11 at 16:19
add comment

2 Answers

up vote 2 down vote accepted

A solution with \minisec, a specific KOMA-Script command, that probably suites better here for the assumed usage:

\documentclass[12pt, headsepline, headings=small,]{scrreprt}
\usepackage[onehalfspacing]{setspace}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathptmx}
\usepackage[a4paper,showframe]{geometry}
\geometry{left=2cm,right=5cm,top=2cm,bottom=2cm}

\usepackage{kantlipsum}% another package for dummy text

\let\OrigMinisec\minisec
\renewcommand{\minisec}[2][0pt]{\vspace{#1}\OrigMinisec{#2}}

\begin{document}

\kant[1]
\minisec{Minisection 1}
\kant[2]
\minisec[-1ex]{Minisection 2}
\kant[3]
\minisec[-0.75\baselineskip]{Minisection 3}
\kant[4]
\minisec[2ex]{Minisection 4}
\kant[5]
\end{document}

According to the definition in the class by default (i.e. when you leave out the optional argument of the redefined version) a vertical skip of 1.5ex is added above minisections.

share|improve this answer
    
Thanks, that's perfect for my purpose :) –  TomM Jan 10 at 23:15
add comment

Just redefine `\paragraph to do what you want.

\documentclass[a4paper, 12pt, headsepline, headings=small,]{scrreprt}
\usepackage[onehalfspacing]{setspace}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathptmx}
\usepackage[a4paper,showframe]{geometry}
\geometry{left=2cm,right=5cm,top=2cm,bottom=2cm}
\usepackage[pangram]{blindtext}

\makeatletter
\renewcommand{\paragraph}{%
  \@startsection{paragraph}{\paragraphnumdepth}%
  {\z@}% title indentation
  {-3pt \@plus -1pt \@minus -1pt }% negative values suppress indent on next paragraph
  {3pt \@plus 1pt \@minus 1pt }% positive value makes a line break after the title
  {\raggedsection\normalfont\sectfont\nobreak\size@paragraph}%
}
\makeatother

\begin{document}

\paragraph{Test}
\Blindtext[1][1]
\paragraph{Test}
\Blindtext[1][1]
\textbf{}
\end{document}

enter image description here

If you want to keep \paragraph, redefine \subparagraph:

\documentclass[a4paper, 12pt, headsepline, headings=small,]{scrreprt}
\usepackage[onehalfspacing]{setspace}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathptmx}
\usepackage[a4paper,showframe]{geometry}
\geometry{left=2cm,right=5cm,top=2cm,bottom=2cm}
\usepackage[pangram]{blindtext}


\makeatletter
\renewcommand{\subparagraph}{%
  \@startsection{subparagraph}{\subparagraphnumdepth}%
  {\z@}% title indentation
  {-3pt \@plus -1pt \@minus -1pt }% negative values suppress indent on next paragraph
  {3pt \@plus 1pt \@minus 1pt }% positive value makes a line break after the title
  {\raggedsection\normalfont\sectfont\nobreak\size@paragraph}%
}
\makeatother

\begin{document}


\subparagraph{Test}
\Blindtext[1][1]
\subparagraph{Test}
\Blindtext[1][1]
\textbf{}
\end{document}

The output is just the same as before.

share|improve this answer
    
hmm I would like to keep paragraph the way it is, if possible, but to change only myparagraph instead. Can I simple replace \renewcommand{\paragraph}{% with \renewcommand{\myparagraph}{% Edit: No that doesn't work because of the definition of myparagraph –  TomM Jan 10 at 23:09
1  
But thanks for your entry egreg. It's also good to know how to redefine paragraph globally –  TomM Jan 10 at 23:17
    
@TomM Do you plan to use \subparagraph? –  egreg Jan 10 at 23:22
1  
@TomM Then redefine \subparagraph! Just add sub everywhere. –  egreg Jan 10 at 23:30
1  
@TomM I added the code. –  egreg Jan 11 at 0:23
show 6 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.