## LaTeX forum ⇒ Text Formatting ⇒ Noindent section first paragraph

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
yiorgosb
Posts: 30
Joined: Mon Aug 02, 2010 11:56 pm

### Noindent section first paragraph

I am using the book class which (at least in my document) indents the first paragraph after a section. I tried to overcome this by redefining the section command as

\let \OldSection \section\renewcommand{\section}[1]{\OldSection{#1} \noindent}

but it has 2 problems.
1. It still leaves a thin space (equal to one character) at the begining of the first paragraph.
2. If I (accidentally) place a new line after \section command it again indents the paragraph.

I then tried
\let \OldSection \section\renewcommand{\section}[1]{\OldSection{#1} \parindent=0in}

but this obviously changes the whole document settings.

Here's an example
\documentclass[a4paper,twoside,11pt]{book}  \usepackage{fontspec} \let \OldSection \section\renewcommand{\section}[1]{\OldSection{#1} \noindent} \begin{document} \section {new sec}Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum  \end{document}

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
yiorgosb wrote:I am using the book class which (at least in my document) indents the first paragraph after a section. […]

Since this is not the default behaviour, you should show this by a minimal example before trying to remedy. The below example doesn't show the described misbehaviour.
\documentclass[11pt,a4paper,english]{book}\usepackage[T1]{fontenc}\usepackage[uft8]{inputenc}\usepackage{babel}\usepackage{blindtext} \begin{document}   \Blinddocument\end{document}

Run this on your machine and see what happens.

Thorsten
LaTeX Community Moderator

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

yiorgosb
Posts: 30
Joined: Mon Aug 02, 2010 11:56 pm
You were right. This example works well.
I found by trial and error the package causing the misbehavior.

It is the {xgreek} package which I had removed from the original example
as I didn't thought it could be the one causing the problem
since it is used specifically for the Greek language only.

Anyway, I post below an example including the "problematic" package.
Since I am only a novice Latex user I don't know how to find the particular line in the package that causes the problem.

\usepackage{fontspec} \usepackage{xgreek} \begin{document} \section{title}Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum\end{document}

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
yiorgosb wrote:[…] It is the {xgreek} package which I had removed from the original example as I didn't thought it could be the one causing the problem since it is used specifically for the Greek language only. […]

It's the object of building a minimal working example (MWE) to find out which part of the code causes a problem (if you follow the instructions). And it couldn't have done any harm if you would have told us that you compile with XeLaTeX.

Now that you found the culprit with the xgreek package, you should submit a bug report to the package maintainer. Don't forget to add a MWE to your report so that the maintainer instantly can comprehend the problem.
LaTeX Community Moderator

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

yiorgosb
Posts: 30
Joined: Mon Aug 02, 2010 11:56 pm
localghost wrote: And it couldn't have done any harm if you would have told us that you compile with XeLaTeX.

As I stated I am only a novice user and I don't know what matters and what does not.
My only purpose for excluding such info was not to burden you with useless (as seemed to me) lines of code.
Anyway, I apologize for the inconvenience. I'll follow your suggestion and file a bug.

So, coming back to the initial question.
Can I force with some way the first paragraph not to indent?

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
yiorgosb wrote:[…] As I stated I am only a novice user and I don't know what matters and what does not. My only purpose for excluding such info was not to burden you with useless (as seemed to me) lines of code. […]

Such things do not really depend on the level of experience. Here's just a short note from the list of avoidable mistakes [1].
localghost wrote:The problem depends on a certain processing, i. e. the compilation with pdfLaTeX. But this information is missing in the description of the problem.

It goes without saying that this also applies to the compilation with XeLaTeX.
yiorgosb wrote:[…] So, coming back to the initial question.
Can I force with some way the first paragraph not to indent?

Why not first wait for an answer of the maintainer? Perhaps he can offer a temporary patch until he releases the next version with the bug fixed.

[1] View topic: Avoidable mistakes
LaTeX Community Moderator

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

CDbile
Posts: 19
Joined: Mon Jan 31, 2011 6:48 pm
Well, I identified the "guilty" lines in the xgreek.sty file :

\let\@afterindentfalse\@afterindenttrue\@afterindenttrue

Of course if you comment them in this file, your code will work fine with no first-paragraph indentation, but this is not a good solution, because the result will be different if you compile your file on another computer. So don't do it.
Unfortunately I'm totally unskilled in TeX programming and I don't know what to put in your .tex file to counter the effect, maybe a TeX guru can solve the problem now that it is clearly identified ? I would be interested in the solution too.
CDbile

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
CDbile wrote:Well, I identified the "guilty" lines in the xgreek.sty file :

\let\@afterindentfalse\@afterindenttrue\@afterindenttrue

[…]

I'd like to know why the package author added these lines into the package code at all. The intended effect is also available with the indentfirst package and the »indentfirst« option for the titlesec package. And I'm surprised that the author considers these lines as "care for the basic rules of typography".
LaTeX Community Moderator

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