1

I am formatting a document in LaTeX.

I have the following code:

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[margin=0.5in]{geometry}
\begin{document}
Hello\\
This is a Latex Document\\
\begin{flushleft}
How to write without a space in the beginning
\end{flushleft}

Please help



\end{document}

I am giving the PDF generated from the below code:

enter image description here

Two problems:

  • Whenever I start the document there is a space with which the document starts
  • And when I start with \begin{flushleft} and end with \end{flushleft} the next line again starts with space.

What I want is: using some package/some commands so that all my text is aligned to the left. Is it possible? I don't want any space to begin with in a line.

CarLaTeX
  • 62,716
  • 3
    Have you tried \usepackage{parskip}? – Mico Sep 10 '18 at 06:07
  • 7
    \setlength{\parindent}{0pt} – LaRiFaRi Sep 10 '18 at 06:07
  • 1
    Also note that it is not legal to use \ outside a tabular environment to start a new line. The only right way way to do so is a blank line. – Denis Sep 10 '18 at 06:18
  • 1
    @PureMathematics Although I prefer Mico's solution as it looks nicer, I would like to point you to the fact that this package replaces the indentation with a small vertical space between the lines of two paragraphs. This is just for you to understand the difference between those two given solutions. – LaRiFaRi Sep 10 '18 at 06:45
  • 1
    @Denis You are mixing up two things: \\ will insert a line break and for that purpose is perfectly suited. Of course, you usually should not insert line breaks manually, but prefer paragraph breaks (blank line or \par). But these are two different aims. – TeXnician Sep 10 '18 at 07:04
  • By default standard document classes of LaTeX have some paragraph indentation (\parindent > 0pt) except in first paragraphs after headings (\section, etc.) instead of a paragraph skip (\parskip of 0pt). Note also that the end of a paragraph is \par or one blank line, whereas \ is only a break of line, so without indentation. – Fran Sep 10 '18 at 07:27
  • 1
    note that the \\ at the ends of paragraph are always wrong (tex will give warnings about badness 10000 (maximum badness)) and give poor output. I – David Carlisle Sep 10 '18 at 07:48
  • 2
    @Denis No, \\ within a paragraph starts a new line, what is wrong is to force a newline at the end of a paragraph. A blank line in the source doesn't start a new line, it starts a new paragraph. – David Carlisle Sep 10 '18 at 07:49
  • Get a couple of books from your shelf: are there indents at the beginning of paragraphs? I guess so. ;-) – egreg Sep 10 '18 at 08:46
  • @DavidCarlisle Clearly right: I meant using \\\ to start a new paragraph. Thanks for clarifying. – Denis Sep 10 '18 at 09:21

0 Answers0