Page Layoutautomating \indent

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
stepec
Posts: 18
Joined: Fri Aug 06, 2010 11:36 pm

automating \indent

Post by stepec »

I'm a newbie to Latex (ordered some books, before anybody says I should :-)

I'm using \documentclass{book} to typset a novel. I wrote the novel in Word (bad me), then discovered the world of Latex, so saved it as a text file, and am now trying to get it to compile properly by using pdflatex in Winshell.

I've figured out how to set chapter headings and even managed to get the headers and footers sorted. But what is bugging me is that, as in many books - and even in this post - the chapters have little sections separated by a blank line. The first paragraph of each of these sections shouldn't be indented, but of course they are. Short of wading through the entire book and keying in \noindent at the start of each of these paragraphs, is there anything I can do?

stepec
Last edited by stepec on Sat Aug 07, 2010 5:01 pm, edited 1 time in total.

Recommended reading 2024:

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

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

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

automating \indent

Post by frabjous »

We need to see a minimal example of the code you’re using that’s creating the problem. How are you creating these blank lines?

Paragraphs immediately following \chapter commands and \section commands are not indented by default in the book class, but I don’t even know how you’re creating these blank lines and what the default value would be there.

Are you trying to make it so that no paragraphs are indented anywhere? If so, then you might want to load the parskip package.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

automating \indent

Post by gmedina »

Hi,

I would recommend changing the document class from book to, for example, scrbook (from the KOMA-Script bundle), since the latter implements mechanisms to eliminate the indentation in every paragraph and to increase the vertical distance between consecutive paragraphs. Refer to the user guide for further details (pages 49 and following).
1,1,2,3,5,8,13,21,34,55,89,144,233,...
stepec
Posts: 18
Joined: Fri Aug 06, 2010 11:36 pm

Re: automating \indent

Post by stepec »

OK.

This is my (unfinished, because I'm learning) code:

\documentclass[12pt,a4paper,oneside]{book}
\setlength{\parindent}{6mm}
\setlength{\headheight}{15pt}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\rhead{\emph{cashmore/ghosts/\thepage}}
\renewcommand{\headrulewidth}{0pt}

\fancyfoot{}
\begin{document}
\title{Ghosts}
\author{S.M.Cashmore}
\date{}
\maketitle

\chapter{}

And this is the problem, in Winshell, some way through the chapter:

90 list and circled Claire with heavy strokes of his pencil. He glanced up as the 91 sun slid behind the greasy clouds again and darkness swept over the street as 92 if someone, somewhere, had pulled a giant curtain.
93
94 ###
95
96 As their gaze met through ochre rays a day or so later, his lips murmured 97 Claire and even though her own lips formed a slight smile, he did not think it

This text is dumped directly from the "save as text" option in Word (sorry line numbers gone skewed for this screen dump). What I want to do is do a search and replace on the ### (which screw up winshell anyway) - specifically, replace the ###, the previous blank line and the following blank line with \medskip and then \noindent so that the "As their gaze met..." paragraph isn't indented.

I can't figure out how to do this, partly because I can't see how to represent a blank line or carriage return in the "search" box and partly because I'm not sure I can insert the \noindent properly.

Obviously I could go through the whole book and insert \noindent at the start if all these sections, which would be a pain.

I could go through and mark them all as sections: also tedious, and this would only work if I could somehow switch off the section head and numbering.

This leaves me with the option of finding some sort of command which reads "after a medskip, don't indent the next paragraph. But that defeats me.

stepec
stepec
Posts: 18
Joined: Fri Aug 06, 2010 11:36 pm

Re: automating \indent

Post by stepec »

Update:

I cunningly replaced all the ### with \section*{} and that has solved the basic problem. Now I'm hard at work trying to figure out how to reduce the space between sections :-)

stepec
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

automating \indent

Post by frabjous »

Try something like this (in the preamble):

Code: Select all

\usepackage{titlesec}
\titlespacing*{\section}%
	{0em}% horizontal space to the left of section title, if any
	{0\baselineskip}% vertical space before section title, set to 0 lines
	{0\baselineskip}% vertical space after section title, set to 0 lines
Adjust the values as you see fit.

See the titlesec documentation for more info.

You might consider defining a command like:

Code: Select all

\newcommand{\secbreak}{\section*{}}
And use that in the body of your document. It is defined as \section*{} so it does the same thing, but this will make it easier to make global changes later on if you change your mind about how these should look; you’ll just need to redefine the command, not find/replace every instance.
stepec
Posts: 18
Joined: Fri Aug 06, 2010 11:36 pm

Re: automating \indent

Post by stepec »

Great stuff. I had found my way to the titlesec package but couldn't make a lot of sense of it. Lo and behold your answer told me I was on the right track and solves the problem. Thanks very much -

- but be warned, I suspect I will be back!

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

automating \indent

Post by localghost »

Now that the problem is solved, please mark the topic accordingly as described in Section 3 of the Board Rules. You should also read the descriptions in Section 2.4 about the tagging of source code.


Best regards and welcome to the board
Thorsten
Post Reply