Text FormattingChange 1st paragraph indent for certain section types

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
tropicofvector
Posts: 6
Joined: Thu Aug 19, 2010 10:10 am

Change 1st paragraph indent for certain section types

Post by tropicofvector »

Hi everybody,

Using TexLive & Texniccenter, I've \renewcommand'ed \paragraph{} and \subparagraph{} as follows.

Code: Select all

\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
  {-3.25ex\@plus -1ex \@minus -.2ex}%
  {1.5ex \@plus .2ex}%
  {\normalfont\normalsize\bfseries\indent}}
\renewcommand\subparagraph{\@startsection{subparagraph}{5}{\z@}%
  {-3.25ex\@plus -5ex \@minus -.2ex}%
  {1.5ex \@plus .2ex}%
  {\normalfont\normalsize\bfseries\indent\it}}
\makeatother
That works fine, \paragraphs will start on a new line after the {} heading, so will \subparagraphs, both do indent fine, the latter is in italics.

However, now I want the "first line" after the "heading" to be indented as well. How would I include that in the \renewcommand? I've tried to simply add indent, but that won't work.

Any ideas?

Thanks a lot in advance!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Change 1st paragraph indent for certain section types

Post by meho_r »

Hi,

1. Please read Board rules

2. Pay attention to section 2.2.: how to build an example.

3. I will assume that under "after the heading" you mean the first line under \paragraph and/or \subparagraph commands. I would suggest using titlesec package for tuning sectioning units instead of "plain" code (see the example below). However, in this case, you may also replace negative numbers with positive in your code to achieve the same result (for testing, just uncomment your code and comment out 4 titlesec related lines above it).

Code: Select all

\documentclass{book}

\usepackage{lipsum}% just for generating some dummy text
\usepackage{titlesec}

\titleformat{\paragraph}{\bfseries}{}{}{}
\titlespacing{\paragraph}{\parindent}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\titleformat{\subparagraph}{\itshape}{}{6pt}{}
\titlespacing{\subparagraph}{\parindent}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

%\makeatletter
%\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
%  {3.25ex\@plus 1ex \@minus .2ex}%
%  {1.5ex \@plus .2ex}%
%  {\normalfont\normalsize\bfseries\indent}}
%\renewcommand\subparagraph{\@startsection{subparagraph}{5}{\z@}%
%  {3.25ex\@plus 1ex \@minus .2ex}% plus 5ex or .5ex??? I put 1ex
%  {1.5ex \@plus .2ex}%
%  {\indent\normalfont\normalsize\bfseries\it}}
%\makeatother

\begin{document}

\paragraph{A paragraph} \lipsum[1]

\subparagraph{A subparagraph} \lipsum[1]

\end{document}
tropicofvector
Posts: 6
Joined: Thu Aug 19, 2010 10:10 am

Change 1st paragraph indent for certain section types

Post by tropicofvector »

Thanks! Works like a spell.

Unfortunately, I lose my section numbering (I think you'd need my preamble in order to see what my settings are? Here it is.)

Code: Select all

\documentclass[12pt,titlepage,draft]{article}
\usepackage{geometry}\usepackage{setspace}
\usepackage[round,semicolon,authoryear]{natbib}
\usepackage{fixltx2e}
\usepackage{tikz}
\usetikzlibrary{trees}
\usepackage{titlesec}

%\makeatletter
%\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
%  {-3.25ex\@plus -1ex \@minus -.2ex}%
%  {1.5ex \@plus .2ex}%
%  {\normalfont\normalsize\bfseries\indent}}
%\renewcommand\subparagraph{\@startsection{subparagraph}{5}{\z@}%
%  {-3.25ex\@plus -5ex \@minus -.2ex}%
%  {1.5ex \@plus .2ex}%
%  {\normalfont\normalsize\bfseries\indent\it}}
%\makeatother

\titleformat{\paragraph}{\bfseries}{}{}{}
\titlespacing{\paragraph}{\parindent}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\titleformat{\subparagraph}{\itshape}{}{6pt}{}
\titlespacing{\subparagraph}{\parindent}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\makeindex
\bibliographystyle{plainnat}

\begin{document}
\setcounter{secnumdepth}{6}
\setcounter{tocdepth}{6}

\paragraph{Questionnaire design for S\textsubscript1 and S\textsubscript2}
***FILLER***
\subparagraph{The S\textsubscript1 questionnaire}
***FILLER***

\end{document}
With my \renewcommand{} fix, the numbered paragraphs were still in both the text and the toc (1.1.1.1. for paragraph and 1.1.1.1.1. for subparagraph).

I've had a look at the titlesec documentation but couldn't find a solution at all.

Any suggestions?

May thanks!
tropicofvector
Posts: 6
Joined: Thu Aug 19, 2010 10:10 am

Re: Change 1st paragraph indent for certain section types

Post by tropicofvector »

Sorry, haven't quite understood your answer correctly. Now have, changed the respective negatives to positives. And it works perfectly.

Thanks!
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Change 1st paragraph indent for certain section types

Post by meho_r »

Titlesec manual, section 3 explains the details. Take a look at the following example:

Code: Select all

\documentclass{article}

\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}

\usepackage{lipsum}% just for generating some dummy text
\usepackage{titlesec}

\titleformat{\paragraph}{\bfseries}{\theparagraph}{0.5em}{}% added the counter and the spacing between the number and the title
\titlespacing{\paragraph}{\parindent}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\titleformat{\subparagraph}{\itshape}{\thesubparagraph}{0.5em}{}% added the counter and the spacing between the number and the title
\titlespacing{\subparagraph}{\parindent}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

%\makeatletter
%\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
%  {3.25ex\@plus 1ex \@minus .2ex}%
%  {1.5ex \@plus .2ex}%
%  {\normalfont\normalsize\bfseries\indent}}
%\renewcommand\subparagraph{\@startsection{subparagraph}{5}{\z@}%
%  {3.25ex\@plus 1ex \@minus .2ex}% plus 5ex or .5ex??? I put 1ex
%  {1.5ex \@plus .2ex}%
%  {\indent\normalfont\normalsize\bfseries\it}}
%\makeatother

\begin{document}

\section{A section}

\paragraph{A paragraph} \lipsum[1]

\subparagraph{A subparagraph} \lipsum[1]

\tableofcontents

\end{document}
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Change 1st paragraph indent for certain section types

Post by localghost »

tropicofvector wrote:[…] Now have, changed the respective negatives to positives. And it works perfectly. […]
Now that the problem is solved, please mark the topic accordingly as described in Section 3 of the Board Rules.


Best regards
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
Post Reply