summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/noindentafter/noindentafter.tex
blob: 6aac2ebe06f7ef6c093be6a5b70e5f36fc819a9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                              %
%  Copyright (c) 2014 - Michiel Helvensteijn - www.mhelvens.net                %
%                                                                              %
%  http://latex-noindentafter.googlecode.com                                   %
%                                                                              %
%  This work may be distributed and/or modified under the                      %
%  conditions of the LaTeX Project Public License, either                      %
%  version 1.3 of this license or (at your option) any later                   %
%  version. The latest version of this license is in                           %
%      http://www.latex-project.org/lppl.txt                                   %
%  and version 1.3 or later is part of all distributions of                    %
%  LaTeX version 2005/12/01 or later.                                          %
%                                                                              %
%  This work has the LPPL maintenance status `maintained'.                     %
%                                                                              %
%  The Current Maintainer of this work is Michiel Helvensteijn.                %
%                                                                              %
%  This work consists of the files noindentafter.tex and noindentafter.sty.    %
%                                                                              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass[a4paper]{noindentafter-packagedoc}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Setup                                                                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NoIndentAfterEnv{latex-example-show}
\NoIndentAfterCmd{\describemacro}

\moretexcs{%
	NoIndentAfterThis,NoIndentAfterEnv,NoIndentAfterCmd
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Global Changes                                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\changes{0.0.1}{2013/08/02}
  {initial version}
\changes{0.2.0}{2014/11/30}
  {new implementation, fixing a spacing issue}
\changes{0.2.2}{2014/11/30}
  {fixed version number in the README}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}                                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\maketitle

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Introduction}                                                         %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Some people prefer certain LaTeX environments ---such as |itemize| or
|theorem|--- never to be followed by an indented paragraph. It is of course
possible to manually add the |\noindent| command to each occurrence, but
it's easy to forget to do this. Also, all those |\noindent| commands leave
your \TeX{} code just a little bit more chaotic and more burdensome to read.

There are a number of solutions floating around, but many of them are not
particularly robust, or only work in specific cases.

The |noindentafter| package provides a few simple commands which can be used
to patch existing macros and environments. They work as expected in all cases
I've encountered.



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Usage}                                                                %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\noindent\DescribeMacro{\NoIndentAfterThis}
%
This is the most primitive macro offered by the package. It forces a
paragraph break and suppresses indentation for whatever follows:

\begin{latex-example-show}
	Lorem ipsum dolor sit amet, consectetur adipiscing
	elit. \NoIndentAfterThis Pellentesque hendrerit volutpat
	feugiat. Ut purus leo, pulvinar sit amet vehicula non,
	pulvinar eu lacus. Curabitur id mollis ligula.
\end{latex-example-show}



\pagebreak % Hack to make the footnote appear on page 1.



\describemacro{\NoIndentAfterEnv}{\marg{environment}}

This is probably the command most people will want to use.
The \meta{environment} argument should contain an environment
name. After using this command, any paragraph following such
an environment will remain unindented.

\begin{latex-example-show}
	Lorem ipsum dolor sit amet, consectetur adipiscing elit.
	
	\begin{itemize}
	  \item First Item
	  \item Second Item
	\end{itemize}
	
	Pellentesque hendrerit volutpat feugiat. Ut purus
	leo, pulvinar sit amet vehicula non, pulvinar eu
	lacus. Curabitur id mollis ligula.
	
	\NoIndentAfterEnv{itemize}
	
	Vestibulum id erat venenatis, facilisis enim non,
	consectetur felis. Quisque iaculis eu arcu non pretium.
	
	\begin{itemize}
	  \item Third Item
	  \item Fourth Item
	\end{itemize}
	
	Curabitur est elit, posuere pulvinar laoreet sed, varius
	id mi. Nam lobortis elit nec mauris condimentum gravida.
\end{latex-example-show}

You'll probably want to use these commands in the document
preamble but, as you can see, you don't really have to.

\needspace{10\baselineskip}
Note that using the |\NoIndentAfterEnv| command on your own
environment is not the same as adding |\NoIndentAfterThis|
to the end of it:

\begin{latex-example-show}
	\newenvironment{test}{\itshape}{\NoIndentAfterThis}
	
	\begin{test}
	    Lorem ipsum dolor sit amet, consectetur
	    adipiscing elit.
	\end{test}
	
	Pellentesque hendrerit volutpat feugiat. Ut purus
	leo, pulvinar sit amet vehicula non, pulvinar eu
	lacus. Curabitur id mollis ligula.
\end{latex-example-show}

|\NoIndentAfterEnv| works because it bypasses the group
that surrounds every \LaTeX{} environment (and localizes
declarations). 



\describemacro{\NoIndentAfterCmd}{\marg{command}}

Finally, you may also patch command sequences using the
|\NoIndentAfterCmd| command. There may not be many situations
where this is useful, but for me, there is at least one:

\begin{latex-example-show}
	Lorem ipsum dolor sit amet, consectetur adipiscing elit:
	
	\[ 1 + 1 = 2 \]
	
	Pellentesque hendrerit volutpat feugiat. Ut purus leo:
	
	\NoIndentAfterCmd \]
	
	\[ 2 + 2 = 4 \]
	
	Vestibulum id erat venenatis, facilisis enim non,
	consectetur felis.
\end{latex-example-show}

Note that braces around the \meta{command} argument are
optional, as always when an argument in \TeX{} consists
of only a single token.



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Acknowledgements}                                                     %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

I had been looking for a solution like this for quite a while. I came up
with a number of hacks that workedin some situations but not in others.
Eventually I asked a question on \url{http://tex.stackexchange.com}:
\begin{itemize}
  \item \url{http://tex.stackexchange.com/questions/112404}
\end{itemize}

I received two excellent answers -- one from cgnieder and one from lockstep.
This package was originally based on the technique proposed by cgnieder, as
it is simpler and more generally applicable. Still, the answer by lockstep
is definitely worth a read.

Most recently, a better approach was implemented by tudscr to fix the spacing
above headers:
\begin{itemize}
  \item \url{https://github.com/mhelvens/latex-noindentafter/pull/1}
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}                                                                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%