Text FormattingNoindent section first paragraph

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

Noindent section first paragraph

Post by yiorgosb »

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

Code: Select all

\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

Code: Select all

\let \OldSection \section
\renewcommand{\section}[1]{\OldSection{#1} \parindent=0in}
but this obviously changes the whole document settings.

Here's an example

Code: Select all

\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}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Noindent section first paragraph

Post by localghost »

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.

Code: Select all

\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
yiorgosb
Posts: 30
Joined: Mon Aug 02, 2010 11:56 pm

Noindent section first paragraph

Post by yiorgosb »

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.

Code: Select all

\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}
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Noindent section first paragraph

Post by localghost »

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.
yiorgosb
Posts: 30
Joined: Mon Aug 02, 2010 11:56 pm

Noindent section first paragraph

Post by yiorgosb »

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?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Noindent section first paragraph

Post by localghost »

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
User avatar
CDbile
Posts: 19
Joined: Mon Jan 31, 2011 6:48 pm

Noindent section first paragraph

Post by CDbile »

Well, I identified the "guilty" lines in the xgreek.sty file :

Code: Select all

\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
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Noindent section first paragraph

Post by localghost »

CDbile wrote:Well, I identified the "guilty" lines in the xgreek.sty file :

Code: Select all

\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".
Post Reply