Log In | Users | Register
Public Web that is accessible worldwide
spacer
Edit | Attach | New | Raw | Delete | History | Diff | Print | Pdf | | Tools
You are here: Public » Diss Latex » Diss Latex Commands

Commands

Latex allows to simplify things which are used often. It's a decision of style how often you will use this things. Very often they make it harder to read the code of the document (especially after a break of some month or for other person which see it the first time). On the other hand they make it easier to create a consistent layout. All this commands are defined before the \begin{document} statement. It's also a good idea to export them to an own file an import them with \input{comdef.tex}

Here some tips and examples

  • If Latex fails by some hyphenation you can explain them to Latex. \hyphenation{syllable-syllable}
  • Often used words can be replaced by short ones. eg: \newcommand{\IOLU}{International organized latex users\xspace}. Inside the text you need only to write \IOLU instead of the whole thing. The \xspace at the end needs the package xspace(\usepackage{xspace}) and handles the problems with space at the end of \IOLU. Don't define hundred of shorts in this style. Your text won't be readable. Another advantage is the uniform formating of all occurrence of them. (\newcommand{\brand}{\textit{brand}\xspace}).
  • For an identical figure style use a command like this:
    \newcommand{\myFig}[5][\columnwidth]{ 
        \begin{figure}[htbp]\begin{center}
        \includegraphics[width=#1]{#2}
        \caption{#3}
        \label{img:#5}
        \small{\textit{#4}}
        \end{center}\end{figure}
        }

    It uses 5 arguments, where the first one is optional: Width of the figure (default: column-width), name of the file, title, caption and reference name (where img: is added by default, to prevent duplicated names).
    Example \myFig[5cm]{psfile.ps}{Overview}{This picture show everything}{everything} or without a given width \myFig{psfile.ps}{Overview}{This picture show everything}{everything} If you define also \newcommand{\fig}[1]{Figure \ref{img:#1}} you can refer the picture just by using \fig{everything} (In the text figure 6 will appear as example).
    The advantage of this two commands is that you can change the layout of all pictures just by changing the command definition.
  • A little bit more complicate is newenvironment but it allows also more complicate things, because you may embed whole text passage.
    {\newenvironment{myTab}[3][]
          {\begin{table}[#1]\begin{center}\caption{#2}\label{tab:#3}\vspace{3mm}}
          {\end{center}\end{table}
        }

    Defines a environment for tables. The arguments are position (optional), title and reference name ( with an additional tab:
    \begin{myTab}{the results of my work}{reswork}
    Caption of the table, the table itself ...
    \end{myTab}

-- JoergMaeder - 20 Dec 2010 spacer

Changed by maederj on 20 Dec 2010 - 16:34 - r1
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Wiki? Send feedback
Syndicate this site RSS ATOM