Difference between revisions of "LaTeX:Style"

(Space)
Line 15: Line 15:
 
\end{document}  
 
\end{document}  
 
</nowiki></pre>
 
</nowiki></pre>
 
 
results in the same as this:
 
results in the same as this:
 
 
 
<pre><nowiki>
 
<pre><nowiki>
 
\documentclass{article}
 
\documentclass{article}
Line 27: Line 24:
  
  
 +
It illustrates how \LaTeX\ treats space.
 +
\end{document}
 +
</nowiki></pre>
 +
Generally, write so that it's easy for you to read the source code. Don't pour in tons of space, but leave enough that you can easily find parts of the source file later.
 +
 +
TeXnicCenter (and most editors you might use for LaTeX) treats line numbering differently than your typical text editor. If you just type and type text without ever hitting <Enter> so that your text scrolls on to the next line, TeXnicCenter sees all that text on the next line as just a continuation of the previous line. This is no big deal if you never make a mistake, but when an error occurs when you compile, you usually have to find the mistake in your source file by line number. If you have a 4 or 5 line 'line', finding the error can be a real headache. (You can see what line you are on in TeXnicCenter by looking at the bottom towards the right.)
 +
 +
Just as LaTeX doesn't see tons of extra space, it won't see space that isn't there. One primary example of this is that LaTeX will only see linebreaks if there is an empty line or if you use the \linebreak command. Hence, this:
 +
<pre><nowiki>
 +
\documentclass{article}
 +
\begin{document}
 +
This is a sample document. It illustrates how \LaTeX\ treats space.
 +
\end{document}
 +
</nowiki></pre>
 +
will produce the same result as:
 +
<pre><nowiki>
 +
\documentclass{article}
 +
\begin{document}
 +
This is a sample document.
 
It illustrates how \LaTeX\ treats space.
 
It illustrates how \LaTeX\ treats space.
 
\end{document}  
 
\end{document}  

Revision as of 16:51, 10 July 2007

LaTeX
About - Getting Started - Diagrams - Symbols - Downloads - Basics - Math - Examples - Pictures - Layout - Commands - Packages - Help

You'll develop your own style of using LaTeX. The sections below outline some tips that you'll find helpful.


Space

In LaTeX, you can use as much space as you like--LaTeX won't see it when it compiles. If you put in three spaces, it will only see one. If you put in 6 empty lines, it's the same as one. Therefore, this:

\documentclass{article}
\begin{document}
This is a sample document.

It illustrates how \LaTeX\ treats space.
\end{document} 

results in the same as this:

\documentclass{article}
\begin{document}
This        is     a        sample document.




It illustrates how \LaTeX\ treats space.
\end{document} 

Generally, write so that it's easy for you to read the source code. Don't pour in tons of space, but leave enough that you can easily find parts of the source file later.

TeXnicCenter (and most editors you might use for LaTeX) treats line numbering differently than your typical text editor. If you just type and type text without ever hitting <Enter> so that your text scrolls on to the next line, TeXnicCenter sees all that text on the next line as just a continuation of the previous line. This is no big deal if you never make a mistake, but when an error occurs when you compile, you usually have to find the mistake in your source file by line number. If you have a 4 or 5 line 'line', finding the error can be a real headache. (You can see what line you are on in TeXnicCenter by looking at the bottom towards the right.)

Just as LaTeX doesn't see tons of extra space, it won't see space that isn't there. One primary example of this is that LaTeX will only see linebreaks if there is an empty line or if you use the \linebreak command. Hence, this:

\documentclass{article}
\begin{document}
This is a sample document. It illustrates how \LaTeX\ treats space.
\end{document} 

will produce the same result as:

\documentclass{article}
\begin{document}
This is a sample document.
It illustrates how \LaTeX\ treats space.
\end{document} 

Comments

Including Packages

See also