[ Skip to the content ]

Institute of Formal and Applied Linguistics Wiki


[ Back to the navigation ]

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revision Both sides next revision
tex:triky [2009/12/14 17:55]
bejcek vytvořeno: headers, lists
tex:triky [2010/12/14 17:32]
bejcek figures side-by-side
Line 10: Line 10:
   * Useful page (and a figure) for **lists**:   * Useful page (and a figure) for **lists**:
     * http://latex.computersci.org/Reference/ListEnvironments     * http://latex.computersci.org/Reference/ListEnvironments
 +
 +  * The **if** condition in TeX:
 +    * construction **if ''\variable'' is empty**:
 +      * ''The variable \if#\variable# is empty.\else contains \variable.\fi''\\ (''\variable'' naturally cannot contain '''#'****'')
 +      * ''The variable \ifx\@empty\variable is empty.\else contains \variable.\fi''
 +    * **comparing** two strings:<code>
 +      \newif\ifsame
 +      \newcommand{\strcfstr}[2]{%
 +       \samefalse
 +       \begingroup
 +        \def\1{#1}\def\2{#2}%
 +        \ifx\1\2\endgroup \sametrue
 +        \else   \endgroup
 +        \fi
 +      }</code>
 +      * (The grouping is needed there to make '\1' and '\2' local but '\sametrue' global.)
 +      * [[http://www.tug.org/TUGboat/Articles/tb22-4/tb72wilson.pdf|(source, Peter Wilson)]]
 +    * allocator **''\newif''** is used in a sequention:\\ a declaration ''\newif\ifsomething''\\ setting either ''\somethingtrue'' or ''\somethingfalse''\\ and asking ''\ifsomething YES\else NO\fi''
 +
 +  * **foreach** in TeX <html><font color="gray" size="-5">(thanks to TMA)</font></html>:
 +    * If you want to ''\dothis{}'' with each word in ''\foreach{Peter, Paul, John, Ringo}'', you can do this as follows:
 +      * ''\def\foreach#1{\first#1,,}''
 +      * ''\def\first#1,{\if,#1,\else\dothis{#1}\expandafter\first\fi}''
 +    * and then write something here:
 +      * ''\def\dothis#1{ ... whatever #1 ... }''
 +
 +  * **Aligning an element** in the line according to whether it fits in the rest of the line (TeX)
 +      * always right-aligned <html><font color="gray" size="-5">(from Petr Olšák's TeXbook naruby)</font></html>:<code>
 +        \def\alignelemright #1\par{\unskip
 +          \nobreak\hfill\penalty71\hskip2em\hbox{}\nobreak\hfill
 +          \hbox{#1}\par}</code>
 +      * always left-aligned:<code>
 +        \def\alignelemleft #1\par{\unskip
 +          \hbox{} \hskip 0pt plus 1fil \penalty0
 +          \hbox{#1}\hskip 0pt plus 1fill\hbox{}\par}</code>
 +      * align to the right, if it fits, or to the left in the new line:<code>
 +       \def\alignelemrightorleft #1\par{\unskip
 +          \nobreak\hfill\penalty71\hskip2em
 +          \hbox{#1}\par}</code>
 +  * Two **tables/figures side-by-side** [[http://texblog.wordpress.com/2007/08/01/placing-figurestables-side-by-side-minipage/|(source)]]:<code>
 +    \begin{figure}
 +     \begin{minipage}[b]{0.5\linewidth}
 +      \centering \includegraphics[scale=1]{fn1} \caption{c} \label{f1}
 +     \end{minipage}
 +     \hspace{0.5cm}
 +     \begin{minipage}[b]{0.5\linewidth}
 +      \centering \includegraphics[scale=1]{fn2} \caption{c} \label{f2}
 +     \end{minipage}
 +    \end{figure}</code>
 +  * Useful **packages**:
 +    * Source printing: //''fancyvrb''//, //''listings''//
 +    * //''fancyhdr''//
 +    * pseudocode //''algorithmicx''//
 +
 +==== počítání slov (a dalších věcí) ====
 +
 +<code>texcount soubor.tex</code>
 +
 +''texcount -inc soubor.tex'' ... započítá správně slova i v souborech vložených v hlavním souboru pomocí ''\include''
 +
 +Podrobnosti v dokumentaci: ''texdoc texcount''
 +
 +<html><hr/></html>
 +
 +Some PBML and SCTL-specific issues are [[https://wiki.ufal.ms.mff.cuni.cz/tex:pbml|here]].

[ Back to the navigation ] [ Back to the content ]