LaTeX/Basics : Différence entre versions
(→LaTeX online pour une copie dans PowerPoint : png) |
(Better example than the French) |
||
| Ligne 1 : | Ligne 1 : | ||
<noinclude>{{LaTeX/Top}}</noinclude> | <noinclude>{{LaTeX/Top}}</noinclude> | ||
| − | === | + | === Hello World basic example === |
{{LaTeX/Usage|code= | {{LaTeX/Usage|code= | ||
| Ligne 10 : | Ligne 10 : | ||
}} | }} | ||
| − | === | + | === Example with maths === |
<source lang="latex"> | <source lang="latex"> | ||
\begin{document} | \begin{document} | ||
| − | + | The cosinus function, $\cos x$, can be defined by the power series | |
| − | + | \[\cos x=\sum_{k=0}^{\infty}\frac{(-1)^k}{(2k)!}x^{2k}\] | |
| − | + | as well as $\sin x$, $\tan x$ etc. | |
\end{document} | \end{document} | ||
</source> | </source> | ||
| − | + | will be displayed: | |
{{début cadre|bleu}} | {{début cadre|bleu}} | ||
| − | + | The cosinus function, <math>\cos x</math>, can be defined by the power series<BR> | |
<CENTER><math>\cos x=\sum_{k=0}^{\infty}\frac{(-1)^k}{(2k)!}x^{2k}</math></CENTER><BR> | <CENTER><math>\cos x=\sum_{k=0}^{\infty}\frac{(-1)^k}{(2k)!}x^{2k}</math></CENTER><BR> | ||
| − | + | as well as <math>\sin x</math>, <math>\tan x</math> etc. | |
{{fin cadre}} | {{fin cadre}} | ||
Version du 28 mai 2011 à 09:55
Sommaire
Hello World basic example
|
\documentclass{article} |
Example with maths
\begin{document} The cosinus function, $\cos x$, can be defined by the power series \[\cos x=\sum_{k=0}^{\infty}\frac{(-1)^k}{(2k)!}x^{2k}\] as well as $\sin x$, $\tan x$ etc. \end{document}
will be displayed:
The cosinus function,
, can be defined by the power series

as well as
,
etc.
LaTeX online pour une copie dans PowerPoint
Il est possible d'envoyer une expression mathématique à un serveur LaTeX et de recopier l'image produite dans un autre logiciel :
http://www.forkosh.dreamhost.com/mimetex.cgi?x=\frac{1-t^2}{1+t^2}
ou encore
http://math.spip.org/tex.php?x=\frac{1-t^2}{1+t^2}
L'image de la formule apparaît alors dans votre navigateur et il suffit d'un clic droit pour enregistrer l'image qui est sous un format .png ou de le copier en mémoire puis de le coller dans une application.
Spaces
"Whitespace" characters, such as blank or tab, are treated uniformly as "space" by LaTeX. Several consecutive whitespace characters are treated as one "space". Whitespace at the start of a line is generally ignored, and a single line break is treated as “whitespace.” An empty line between two lines of text defines the end of a paragraph. Several empty lines are treated the same as one empty line. The text below is an example. On the left hand side is the text from the input file, and on the right hand side is the formatted output.
|
It does not matter whether you |
It does not matter whether you enter one or several spaces after a word. An empty line starts a new paragraph. |
Special Characters
The following symbols are reserved characters that either have a special meaning under LaTeX or are unavailable in all the fonts. If you enter them directly in your text, they will normally not print, but rather make LaTeX do things you did not intend.
# $ % ^ & _ { } ~ \
As you will see, these characters can be used in your documents all the same by adding a prefix backslash:
|
\# \$ \% \textasciicircum{} \& \_ \{ \} \~{} \textbackslash{} |
The other symbols and many more can be printed with special commands in mathematical formulae or as accents.
The backslash character \ can not be entered by adding another backslash in front of it (\\); this sequence is used for line breaking. For introducing a backslash in math mode, you can use \backslash instead.
The command \~ produces a tilde which is placed over the next letter. For example \~n gives ñ. To produce just the character ~, use \~{} which places a ~ over an empty box.
Similarly, the command \^ produces a hat over the next character, for example \^{o} produces ô. If you need in text to display the ^ symbol you have to use \textasciicircum.
If you want to insert text that might contain several particular symbols (such as URIs), you can consider using the \verb command, that will be discussed later in the section on formatting.
LaTeX Commands
LaTeX commands are case sensitive, and take one of the following two formats:
- They start with a backslash \ and then have a name consisting of letters only. Command names are terminated by a space, a number or any other "non-letter".
- They consist of a backslash \ and exactly one non-letter.
Some commands need an argument, which has to be given between curly braces { } after the command name. Some commands support optional parameters, which are added after the command name in square brackets [ ]. The general syntax is:
|
\commandname[option1,option2,...]{argument1}{argument2}... |
LaTeX environments
Environments in LaTeX have a role that is quite similar to commands, but they usually have effect on a wider part of the document. Their syntax is:
|
\begin{environmentname} |
Between the \begin and the \end you can put other commands and nested environments. In general, environments can accept arguments as well, but this feature is not commonly used and so it will be discussed in more advanced parts of the document.
Anything in LaTeX can be expressed in terms of commands and environments.
Comments
When LaTeX encounters a % character while processing an input file, it ignores the rest of the current line, the line break, and all whitespace at the beginning of the next line.
This can be used to write notes into the input file, which will not show up in the printed version.
|
This is an % stupid |
This is an example: Supercalifragilisticexpialidocious |
Note that the % character can be used to split long input lines that do not allow whitespace or line breaks, as with Supercali...cious above.
The core LaTeX language does not have a predefined syntax for commenting out regions spanning multiple lines. Refer to multi-line comments for simple workarounds.