LaTeX forum ⇒ Text FormattingNoindent 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

Postby yiorgosb » Tue Mar 29, 2011 10:36 am

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

  1. \let \OldSection \section
  2. \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
  1. \let \OldSection \section
  2. \renewcommand{\section}[1]{\OldSection{#1} \parindent=0in}

but this obviously changes the whole document settings.

Here's an example
  1. \documentclass[a4paper,twoside,11pt]{book}
  2.  
  3.  
  4. \usepackage{fontspec}
  5.  
  6. \let \OldSection \section
  7. \renewcommand{\section}[1]{\OldSection{#1} \noindent}
  8.  
  9. \begin{document}
  10.  
  11. \section {new sec}
  12. 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
  13.  
  14. \end{document}

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

Postby localghost » Tue Mar 29, 2011 10:49 am

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.
  1. \documentclass[11pt,a4paper,english]{book}
  2. \usepackage[T1]{fontenc}
  3. \usepackage[uft8]{inputenc}
  4. \usepackage{babel}
  5. \usepackage{blindtext}
  6.  
  7. \begin{document}
  8. \Blinddocument
  9. \end{document}

Run this on your machine and see what happens.


Thorsten
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ 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

Postby yiorgosb » Tue Mar 29, 2011 7:44 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.

  1. \usepackage{fontspec}
  2.  
  3. \usepackage{xgreek}
  4.  
  5. \begin{document}
  6.  
  7. \section{title}
  8. 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
  9.  
  10. 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
  11. \end{document}

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

Postby localghost » Tue Mar 29, 2011 8:43 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
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ 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

Postby yiorgosb » Tue Mar 29, 2011 11:50 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?

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

Postby localghost » Wed Mar 30, 2011 9:26 am

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
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


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

User avatar
CDbile
Posts: 19
Joined: Mon Jan 31, 2011 6:48 pm

Postby CDbile » Thu Mar 31, 2011 11:48 pm

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

  1. \let\@afterindentfalse\@afterindenttrue
  2. \@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: 9204
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Fri Apr 01, 2011 10:20 am

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

  1. \let\@afterindentfalse\@afterindenttrue
  2. \@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
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


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


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 6 guests