[ 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
tex:triky [2010/09/10 05:12]
bejcek crossreference TeX->PBML tricks
tex:triky [2019/09/09 16:37] (current)
lauschmannova [pdf-a verification of theses]
Line 1: Line 1:
 +====== Central TeXLive distributions ======
 +
 +If you are using TeXLive on your linux workstations you may use texlive-full portable installed in:
 +
 +  /opt/texlive
 +  
 +There are folders for several years backward up to the latest distribution.
 +
 +In order to use the shared TeX binaries from the command line, you may want to add the following line to your .bashrc:
 +
 +  export PATH=/opt/texlive/2018/bin/x86_64-linux/:$PATH
 +
 +=== Texstudio ===
 +You may use {{ :latex:texlive-portable2018-full.zip |this}} config file for setting up **texstudio** to use version from 2018.
 +
 ====== Tips and Tricks for LaTeX ====== ====== Tips and Tricks for LaTeX ======
  
 +  * see also [[::it-tricks#latex-pdf|IT-tricks with LaTeX and pdf]]
   * For the redefining the **header**, you can use   * For the redefining the **header**, you can use
     * ''\markboth'' -- two parameters (left and right page) or ''\markright'' with just one parameter     * ''\markboth'' -- two parameters (left and right page) or ''\markright'' with just one parameter
Line 15: Line 31:
       * ''The variable \if#\variable# is empty.\else contains \variable.\fi''\\ (''\variable'' naturally cannot contain '''#'****'')       * ''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''       * ''The variable \ifx\@empty\variable is empty.\else contains \variable.\fi''
-    * **comparing** two strings:\\ ''\newif\ifsame\\ \newcommand{\strcfstr}[2]{%\\ \ \samefalse\\ \ \begingroup\\ \ \ \def\1{#1}\def\2{#2}%\\ \ \ \ifx\1\2\endgroup \sametrue\\ \ \ \else   \endgroup\\ \ \ \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.)       * (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)]]       * [[http://www.tug.org/TUGboat/Articles/tb22-4/tb72wilson.pdf|(source, Peter Wilson)]]
Line 28: Line 53:
  
   * **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**:   * Useful **packages**:
     * Source printing: //''fancyvrb''//, //''listings''//     * Source printing: //''fancyvrb''//, //''listings''//
     * //''fancyhdr''//     * //''fancyhdr''//
     * pseudocode //''algorithmicx''//     * 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''/''\cmidrule'', ''\bottomrule'' instead of ''\hline''/''\cline'') (all from this [[http://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')
 +  * **New** type of **float** and its **List of**<code>
 +   \usepackage{tocloft} 
 +   \newlistof{graphs}{grp}{List of Graphs}                     % new list, file extension, its name
 +     \renewcommand{\cftgrptitlefont}{\sffamily\bfseries\huge}  % style of list title
 +     \setlength{\cftbeforegrptitleskip}{10ex}                  % space above list title
 +     \setlength{\cftaftergrptitleskip}{4ex}                    % space below list title
 +     % previous three lines alternatively (in pbmlbook class): \cfttitleset{grp}
 +   \newlistentry{graph}{grp}{0}                                % one line of the list (because it will be of type 'graph', not 'graphs', due to float named 'graph')
 +     \renewcommand{\cftgraphfont}{\sffamily}                   % entry style
 +     \renewcommand{\cftgraphpagefont}{\sffamily}               % page number style
 +     \setlength{\cftgraphnumwidth}{2em}                        % space for graph number
 +     % previous three lines alternatively (in pbmlbook class): \cftlineset{graph}{}{2em}
 +
 +   \usepackage{float} 
 +   \newfloat{graph}{ht!}{grp}                                  % new float environment {graph}, "place it here or at the top of page" by default
 +     \floatname{graph}{Graph}                                  % each caption is started as "Graph \thegraph: <captioin>"
 +   ...
 +   \begin{graph}
 +     \centering 
 +     \includegraphics[scale=.8]{obr09}
 +     \caption{Graph Caption}\label{graph:first}
 +   \end{graph}
 +   ...
 +   \cleardoublepage\listofgraphs\phantomsection\addcontentsline{toc}{chapter}{List of Graphs}</code>
 +  * **Crop** PDF **figure** by LaTeX<code>
 +   \graphicspath{{./images/}}
 +   \fbox{\includegraphics[scale=.4,trim=70 150 120 110,clip]{filename}}</code>
 +    * it't left bottom right top and crop ''./images/filename.pdf''!
 +    * ''fbox'' -- for debugging
 +    * ''scale'' or ''width'' or ''height''
 +    * other useful: ''bb=10 10 10 10'', ''angle=45'', ''keepaspectratio'', ''draft''
 +  * Special counter/style/... in **enumerate**<code>
 +   \renewcommand{\labelenumi}{\Alph{enumi}.}
 +   \setcounter{lastenumi}{\theenumi}
 +   \begin{enumerate}
 +     \setcounter{enumi}{\thelastenumi}
 +     ...</code>
  
 ==== počítání slov (a dalších věcí) ==== ==== počítání slov (a dalších věcí) ====
Line 52: Line 147:
  
 Podrobnosti v dokumentaci: ''texdoc texcount'' Podrobnosti v dokumentaci: ''texdoc texcount''
 +
 +==== Fonts ====
 +
 +  * ''fc-list'' -- list of known fonts
 +     * ''fc-list :lang=cs''
 +  * any font in ''~/.fonts'' is immediately found and ready for use
 +  * other font directories can be specified in ''~/.fonts.conf'' in ''dir''-element: ''<dir>~/.fonts</dir>''
  
 <html><hr/></html> <html><hr/></html>
  
-Some PBML and SCTL-specific issues are [[https://wiki.ufal.ms.mff.cuni.cz/tex:pbml|here]].+Some [[https://wiki.ufal.ms.mff.cuni.cz/tex:pbml|PBML]] and [[https://wiki.ufal.ms.mff.cuni.cz/tex:sctl|SCTL]]-specific issues can be found at these links. 
 + 
 +====== pdf-a verification of theses ====== 
 +All theses submitted at the Charles University must be in the pdf-a format, 
 +following a specific set of requirements defined by a university profile. 
 +`/lnet/ms/projects/verapdf/checkpdf` in the ufal internal network is a wrapper for the verapdf tool which you can use to check whether your thesis fulfills these requirements. New university profiles appear regularly at   
 +https://cuni.cz/UK-7987.html , so don't rely on the default. 
 + 
 +[[vernerova@ufal.mff.cuni.cz|Anša's]] experience: 
 +I used Eda's LaTeX template (send me an e-mail if you want to get it) and no amount of tweaking would give me a valid pdf-a, even though I was using  
 +    \usepackage[a-2u]{pdfx} 
 +and compiling with a wrapper script containing the line  
 +    LC_ALL=cs_CZ.UTF-8 xelatex -shell-escape -output-driver="xdvipdfmx -z 0" -synctex=1 "$@" 
 +I sent my pdf file to [[https://www.mff.cuni.cz/cs/fakulta/organizacni-struktura/lide?hdl=2684|Petra Hoffmannová from the library]], who ran my pdf file through Adobe Acrobat (the library has a commercial licence)... and voilà, it was a valid pdf-a. Unlike verapdf, Acrobat also gives a detailed summary of the exact issues with your file (like which piece of text in which image fails the validation).

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