latex - Latex Document - latex tutorial



What is Latex Document?

  • LaTeX is a high-quality typesetting system; it includes features designed for the production of technical and scientific documentation.
  • LaTeX is the de facto standard for the communication and publication of scientific documents.
 Latex Document

learn latex tutorial - Latex Document - latex example

Types of documentation:

  • Basic layout
  • Title pages

The basic layout of a $\LaTeX$ file:

  • Creating documents with LaTeX is simple and fun. In contrast to Word, you start off with a plain text file (.tex file) which contains LaTeX code and the actual content (i.e. text).
  • LaTeX uses control statements, which define how your content should be formatted.
  • Before you can see what the final result looks like, the LaTeX compiler will take your .tex file and compile it into a .pdf file.

latex document workflow :

learn latex tutorial - latex document workflow - latex example programs

learn latex tutorial - latex document workflow - latex example programs

Example coding:

\documentclass{article}

\begin{document}

     Hello World!

\end{document}
  • Once you translated this code into a PDF document, you will find the text:

Hello World!
  • Along with the page number at the bottom, which is added automatically when using the article class.
  • Let us now take a closer look at how the magic happens.
  • As you can see, you will find a few statements beginning with a backslash \ in the code example which is mentioned above.
  • This tells LaTeX that this is not actual text, that you want to see printed in your document, but instead is an instruction or command for the LaTeX compiler.
  • All commands share the following structure: \commandname{option}.
  • The first part indicates the name of the command and the second part in braces sets an option for this command.
  • The options vary from command to command.
  • Most of the time, the commands are pretty self-explanatory: \documentclass{article} and what's even greater, you don't have to remember all of them, because you can later just copy and paste them from previous documents. Now let's see the command \documentclass{article}.
  • The command is named as documentclass and it does exactly that, it sets the document class (to article).
  • LaTeX uses document classes, to influence the overall layout of your document.
  • For instance, there's one class to layout articles, one class to layout books (called book) and many more, which we probably don't need.
  • I will always use the class article. Feel free to play around and try different document classes anyway and see what happens!
  • This second example differs slightly from the first one, since this command involves a \begin and \end statement.
  • In fact this is not a command, but defines an environment.
  • An environment is simply an area of your document where certain typesetting rules apply.
  • It is possible (and usually necessary) to have multiple environments in a document, but it is imperative the document environment is the topmost environment.

Coding:

% Valid:

\begin{document}

  \begin{environment1}

    \begin{environment2}
   
       \end{environment2}

    \end{environment1}

\end{document}

%Invalid:

\begin{document}

   \begin{environment1}
   
	       \begin{environment2}

      \end{environment1}

    \end{environment2}

\end{document}

% Invalid:

\begin{document}

  \begin{environment1}

\end{document}

  \end{environment1}

% Also invalid:

\begin{environment}

  \begin{document}

  \end{document}

\end{environment}

Adding a title page:

  • There are numerous choices for environments and you will most likely need them as soon as you introduce large parts of mathematics or figures to your document.
  • While it is possible to define your own environments, it is very likely that the environment you desire already exists.
  • LaTeX already comes with a few predefined environments and even more come in so called packages.

Sample Code:

\documentclass{article}

\title{My first document}

\date{2013-09-01}

\author{John Doe}

\begin{document}

  \maketitle

  \newpage

  Hello World!

\end{document}
  • The statements \title, \date and \author are not within the the document environment, so they will not directly show up in our document.
  • The area before our main document is called preamble. In this specific example we use it to set up the values for the \maketitle command for later use in our document.
  • This command will automatically create a titlepage for us. The \newpage command speaks for itself.
  • If we now compile again, we will see a nicely formatted title page, but we can spot a page number at the bottom of our title page.
  • What if we decide, that actually, we don't want to have that page number showing up there.
  • We can remove it, by telling LaTeX to hide the page number for our first page.
  • This can be done by adding the \pagenumbering{gobble} command and then changing it back to \pagenumbering{arabic} on the next page numbers like so:

Sample Code:

\documentclass{article}

\title{My first document}

\date{2013-09-01}

\author{John Doe}

\begin{document}

  \pagenumbering{gobble}

  \maketitle

  \newpage

  \pagenumbering{arabic}

     Hello World!

\end{document}
  • That's it. You've successfully created your first LaTeX document.

latex document structure :

learn latex tutorial - latex document  structure - latex example programs

learn latex tutorial - latex document structure - latex example programs

latex document creation guidelines :

learn latex - latex tutorial - latex document creation guidelines - latex example programs

learn latex - latex tutorial - latex document creation guidelines - latex example programs

How to Run Latex :

learn latex - latex tutorial - how to run latex - latex example programs

learn latex - latex tutorial - how to run latex - latex example programs



Related Searches to Latex Document