[ 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

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
tex:triky [2010/01/07 17:25]
bejcek Aligning of the special last element in the line
tex:triky [2011/12/29 17:49]
bejcek higher rows/cells in tables
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>:   * **foreach** in TeX <html><font color="gray" size="-5">(thanks to TMA)</font></html>:
Line 19: Line 37:
  
   * **Aligning an element** in the line according to whether it fits in the rest of the line (TeX)   * **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>: +      * always right-aligned <html><font color="gray" size="-5">(from Petr Olšák's TeXbook naruby)</font></html>:<code> 
-<code>       \def\alignelemright #1\par{\unskip+        \def\alignelemright #1\par{\unskip
           \nobreak\hfill\penalty71\hskip2em\hbox{}\nobreak\hfill           \nobreak\hfill\penalty71\hskip2em\hbox{}\nobreak\hfill
           \hbox{#1}\par}</code>           \hbox{#1}\par}</code>
-        * always left-aligned: +      * always left-aligned:<code> 
-<code>        \def\alignelemleft #1\par{\unskip+        \def\alignelemleft #1\par{\unskip
           \hbox{} \hskip 0pt plus 1fil \penalty0           \hbox{} \hskip 0pt plus 1fil \penalty0
           \hbox{#1}\hskip 0pt plus 1fill\hbox{}\par}</code>           \hbox{#1}\hskip 0pt plus 1fill\hbox{}\par}</code>
-      * align to the right, if it fits, or to the left in the new line: +      * align to the right, if it fits, or to the left in the new line:<code> 
-<code>       \def\alignelemrightorleft #1\par{\unskip+       \def\alignelemrightorleft #1\par{\unskip
           \nobreak\hfill\penalty71\hskip2em           \nobreak\hfill\penalty71\hskip2em
           \hbox{#1}\par}</code>           \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>
 +  * **Include completed PDF** and add page numbers and other headings: ''\usepackage{pdfpages}''<code>
 +    % settings
 +    \markright{Author Name}    % or e.g. package fancyhdr
 +    \setcounter{page}{13}      % number of first page
 +    % inserting (first page with pagenumber in the foot, others in the head with author name)
 +    \includepdf[pages=1, pagecommand={\thispagestyle{plain}}]{file.pdf}
 +    \includepdf[pages=2-, pagecommand={\thispagestyle{myheadings}}]{file.pdf}</code>
 +  * ''\textwidth'', ''\linewidth'', ''\columnwidth'', ''\hsize'' and others explained [[http://tex.stackexchange.com/questions/16942/difference-between-textwidth-linewidth-and-hsize|here]] (You want ''\linewidth'' in most cases.)
 +  * Useful **packages**:
 +    * Source printing: //''fancyvrb''//, //''listings''//
 +    * //''fancyhdr''//
 +    * pseudocode //''algorithmicx''//
 +    * trees: //''xytree''// (complicated), //''dtree''// (Obo, pstricks), //''xyling''// (Martin P., ''\B'' and ''\T'' must be relaxed)
 +    * tables: //''xtab''// (better than ''longtable'' or ''supertabular''), //''tabulary''// (pretty wrapped text in autosized cells, similar to ''tabularx''), //''booktabs''// (no vertical lines, ''\toprule'', ''\midrule'', ''\bottomrule'' instead of ''\hline'') (all from this [[www.tug.org/pracjourn/2007-1/mori/mori.pdf|compendium]])
 +  * ''longtable'' or ''xtabular'' environment **cannot** be inside ''table'' environment. (Put it inside ''center'' instead, since you cannot use ''\centering'' as before.) 
 +  * **Higher cells/rows in tables** can be achieved either by ''booktabs'' package, or (if you have to use **vertical lines** in tables) by inserting ''\toppadding'' and ''\bottompadding'' in every row:<code>
 +    \newcommand\toppadding{\rule{0pt}{2.6ex}}
 +    \newcommand\bottompadding{\rule[-1.2ex]{0pt}{0pt}}
 +    ...
 +    \hline
 +    \toppadding First cell\bottompadding & Second cell & Third one \\
 +    \hline
 +    ...</code>
 +  * ''hyperref'' package:
 +    * If some **links from ToC** point to **incorrect** objects (e.g. section III.2.5 points to the page where the section I.2.5 starts), then the problem is in internal hyperref naming convention (both section in the example are represented as 'section.2.5'). You can change it either by
 +      * ''naturalnames=true'' (=> 'section.III.2.5'), or
 +      * ''hypertexnames=false'' (=> 'section.289')
 +
 +==== 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 ]