2

I would like to use \begin{flushleft} and \end{flushleft} to begin and end to align paragraphs to the left in ShareLaTex. However, I notice that when use those commands, they delete the blank space between paragraphs. I usually type \\ twice to create blank space between paragraph, one right at the end of the first paragraph, and the second between the first and second paragraph.

The followings are what I use for environment. Please let me know what went wrong, thanks for your time.


\documentclass[12pt]{article} 
\usepackage[margin=1in]{geometry} 
\usepackage{amsmath} 
\usepackage{amssymb} 
\usepackage{MnSymbol} 
\usepackage{changepage} 
\newenvironment{indent1}{\begin{adjustwidth}{.5cm}{}}{\end{adjustwidth}}
\newenvironment{indent2}{\begin{adjustwidth}{1cm}{}}{\end{adjustwidth}} 

\begin{document} 
\begin{noindent} 

\end{noindent}
\end{document} 
  • Regardless of the sorry state of this question whose code has basocally nothing to do with it, if you want more space between paragraphs you can add \vspace{...} where ... is any length, so a number followed by pt, cm, mm, pc,ex, em or aany dimension TeX knows of. You can also add the ... after \` as \[...]. If you use \par` for paragraph breaks, I think modifying \parskip (e.g. by \parskip10pt where 10pt is an incarnation of the ... above, should add (or remove) space between paragraphs, but I'd advise you to find more info on that since I never touched that parameter. – MickG Mar 23 '15 at 16:34
  • The indentation is \parindent which can be modified in the same wway. – MickG Mar 23 '15 at 16:34
  • Ratyping part of the above comment to fix backtick misplacements. «You can also add the ... after \\ as \[...\]. If you use \par for paragraph breaks,» et cetera. – MickG May 23 '15 at 16:40
  • Actually, I think I meant «… after \\ as \\[…]». Only just figured this out, and it is too late to edit the previous comment. – MickG May 23 '15 at 16:54
  • I decided to sum up everything that came out on this page, and add something more, in a big answer I just posted. Hope it is useful :). – MickG May 23 '15 at 17:50
3

\\ and certainly \\\\ do not create a paragraph break, the first forces a line break and the second should never be used. To make a paragraph break just use a blank line in the source.

You do not say the intention of the noindent environment but it is very weird, relying on the fact that latex environments call the underlying command form.

\begin{noindent}

\end{noindent}

is the same as

{\noindent

}

So it starts a paragraph with no indentation but no visible text?

\begin{noindent}

aaaa

\end{noindent}

would have a blank line with a spurious paragraph made by \noindent with no text, then a paragraph, then a new indented paragraph with aaaa.

  • If I understand you correctly, you are commenting me on two different issues: (a) I should not use "\\" twice, one at the end of paragraph is enough, to be followed by a blank line in the source; (b) The \begin{noindent} and \end{noindent} do not make any sense at all. Am I understanding you correctly? Thank you. – Amanda.M Mar 18 '15 at 21:58
  • @A.Magnus (a) No! One \\ at the end of the paragraph is wrong! Do not use \\ at all. Just use a blank line. (b) yes \noindent is doing nothing useful in that form (and in 25 years of latex use I've never seen it used that way:-) – David Carlisle Mar 18 '15 at 22:32
  • @A.Magnus I didn't suggest what markup you should use as I couldn't guess the intent of the code fragment (which didn't use flushleft or \\ that you mention in the question, and while you did mention those in the question you didn't say what you were trying to typeset) – David Carlisle Mar 18 '15 at 22:34
  • Thanks again. I learned LaTex from here and there on the spot in no apparent consistency, for that reason (I think) my knowledge is just a hodgepodge of everything :-). My question does not make any sense at all, perhaps because I did not see the pdf file correctly. Let me ask this question, and hope it makes sense this time: Forget about what I have asked, is it true that if you use \textbf{} command, then the resulting paragraph is not only in bold font, but also becomes centered? Thanks again for your time and help. – Amanda.M Mar 18 '15 at 23:18
  • @A.Magnus No \textbf doesn't have paragraph scope at all it just selects the bold font for its argument, zzz \textbf{hello} zzz makes "zzz hello zzz" – David Carlisle Mar 18 '15 at 23:30
0

To summarize everything that emerged from this post, I post an answer as CW.

First of all, \\ does not create a paragraph break. It simply forces a linebreak. What is the difference, you may ask. Well, it depends on the internal parameters of TeX, but a new paragraph will be indented and may have a space before it. The indentation is governed by \parindent, so saying, for example, \parindent 20pt makes the paragraph indent 20pt long. A pt is a unit of measure for length commonly used in typography. To know how long the indentation is set at a specific point in your document, just say \the\parindent. THis may return more than one number. In that case, you will have something of the form xxx pt plus yyy pt minus zzz pt. That is a length of xxx pt allowed to stretch by yyy pt and shrink by zzz pt. This might be of use to adjust the first line of a paragraph. FOr example, suppose you have a short first line. If it is very short, to justify it you will have to make huge spaces. Stretching the indentation could make the spaces smaller. On the other hand, shrinking it might allow to break the line further, and get more text on the first line. TeX is great at calculating the best way to break lines. But not infallible, unfortunately :). Sometimes it does some pretty bizarre breaks with consequent Overfull \hboxes. The space between paragraphs is controlled by \parskip, which can be set the same way, and whose value you can investigate the same way. Stretching and shrinking of \parskip might be handy to avoid a single line at the bottom of the page, where stretching a paragraph separation could send the line to the next page, or to avoid a single line left on the next page, by shrinking. Another way to set both these parameters is \setlength{\parindent}{20pt}, which is equivalent to \parindent 20pt. Naturally, you can specify stretching and shrinking, as \parindent 15pt plus 1 pt minus 3pt.

Various units of measure are accepted by TeX. You should search elsewhere for a list.

To create a new paragraph, you must say \par, or you can leave a blank line. I now want to expand a bit on this. WHen you press the return key, an invisible character called END OF LINE is inserted. On screen, you will see a change of line. When TeX sees an END OF LINE, it turns it into a blank space, which is why changes of line in the source are often ignored, but if there is another END OF LINE immediately afterwards, both of them are turned into a \par. So leaving a blank line = two END OF LINE characters = \par = paragraph break.

The noindent environment simply adds a \noindent at its start. It is probably defined in a way similar to \newenvironment{noindent}{\noindent}{}. The command \noindent simply suppresses the \parindent for the paragraph at whose start it is placed. This can be useful if you don't want the indentation in a particular paragraph. Note that \clearpage also indents text on the new page, so \noindent can come in handy in that situation too.

THe command \\, as I said before, simply forces a linebreak. Therefore, two \\s will break the line twice, causing a blank line to appear between the two blocks of text. \\ accepts an optional argument, which is a length (e.g. 20pt), placed in square brackets immediately after the command (e.g. \\[20pt]), which specifies a length of vertical whitespace to be left after that command before placing the next line of text. It works exactly like \\ in tables or matrices, and not by consequence, since it is the same command.

The flushleft environment, as you probably know, aligns a paragraph on the left. flushright is its right-aligning analogue. center is the environment for centering. I personally discourage the first two, since text is automatically justified by TeX, and justified text looks, in my opinion, much better than left-aligned or right-aligned text. But then, de gustibus. Centering text highlights it, and therefore may be useful for small titles dividing your text. \section and \subsection may be useful for the same purpose, or even \subsubsection.

The space that seemed to be deleted was therefore due to the blank line. To get it back with flushleft, you can either use \\\\ inside flushleft (which is a no-no), or you can use \vspace{…} with a length in the place of … at the end of the paragraph, or you can use \\[…] as explained above. If I were you, I would go for setting \parskip to, say, 1em or so, and then using \par inside flushleft. I suppose that would do the trick. Or you could use \\[…], but then you have no indentation.

Side notes. First, in a comment you mentioned \textbf. THis command only affects its argument, i.e. what is placed in a brace pair after it. As David stated, zzz \textbf{hello} zzz produces "zzz hello zzz". It certainly has nothing to do with any centering. I wonder how you came to link centering with \textbf

THe code you posted seems totally disconnected from the question, and is certainly not a minimal example. WHen you post a problem, if possible, it is advisable to post a MWE, or minimal working example. "working" doesn't mean the code works. It means it shows your problem and can be executed by other users as a basis to "work" on a solution to your problem. Your code neither shows your problem, nor is minimal, since you have many unnecessary packages loaded and two environment definitions at the beginning.

To make your comments and questions better readable, you should highlight code by putting it in backticks ```. For example, writing \textbf between two of those produces \textbf. DOing this, you mark code as code, which helps read what you post. Enclosing text in stars or underscores makes it italic. Double stars make it bold. (_italic_, *italic*, **bold**, to make myself clear). I do not have the link to a Markdown tutorial, but other users surely do, and I invite them to add it into this answer for your benefit. I will not explore markdown, which is the syntax for formating used over here at SX, any further.

What else did I want to say? Oh well, I've forgotten :). Let me point you to some references for learning LaTeX. This is a nice short introduction, a good start. Well, maybe not so short. This is another good reference, though very long. Here is another great place to start with LaTeX. Here are some things about math in TeX. THis and this can be thought of as "manuals" about TeX, which is the program underlying LaTeX. LaTeX itself is "just" a series of commands built on top of TeX, like a library for a programming language. packages are more sets of macros.

Hope you enjoy using LaTeX and benefit from this answer. Good day :).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.