Friday, October 4, 2013

LaTeX Typesetting Hacks (Continuously Updating)

This list of knowledge is a collection of common problems encountered in everyday typesetting. The solution is either seen by reading package manuals of LaTeX related websites. But here I would like to give a list of clear reference (let's do it in factory mode). I've evaluated different solutions and try to make the hacks as simple as possible.

  • By default, hyperref packages creates a colorful border for links. To remove it,

    %remove colorful borders on links without updating the package
        pdfborder = {0 0 0}
  • How to use "List of Algorithms" as toc title and "Algorithms" for single title instead of "List of Listings" while using listings package?

    %listing customization
    \renewcommand{\lstlistingname}{Algorithm}% Listing -> Algorithm
    \renewcommand{\lstlistlistingname}{List of \lstlistingname s}% List of Listings -> List of Algorithms
  • How not to break hypen in bibliography?

    %bibliography no break hypen
  • How to add bibliography to the table of contents?

    \usepackage[nottoc]{tocbibind} %add bibliography to toc
  • How to use "bibliography" instead of "references"?

  • How to enlarge margin paragraph width without using geometry package since it rewrites all the default layout values?

    %set twice as default
  • How to center texts?

    %maybe you are looking for \vspace{2cm} too?
    This is centered text.
  • How to give remarks in red?

    %you can define a macro \remark in the preamble
    \newcommand{\remark}[1]{{\color{red}REMARK: #1}}
    %then in the document
    \remark{This is a remark in red.}
  • To include Chinese/Japanese/Korean letters or characters along with pdflatex, use CJK package. Alternatively, one can choose xelatex. See CJK Doc. Notice CJK env uses two extra options to specify the encodings and font family. One can check out supported font family by checking the folder /usr/share/texmf/tex/latex/CJK/UTF8 or similar. If the font parameter is empty, the default value given in CJK.enc will be selected. On my machine, I have c70bkai.fd installed in that folder. One can also refer install CJK support to see how to manually install a CJK font to the tex tree.

    %to merge CJK with another environment, embed that environment within CJK, such as
  • An example of including a centered figure with caption and label.

    \caption{sample picture}
  • How to put two pictures side by side with each of its own caption and label?

    \subfigure[Caption a]{
    \subfigure[Caption b]{
    \caption{Two figures}%
  • How to introduce plain codes?

    int sched_setscheduler(pid_t pid, int policy,
                           const struct sched_param *param);
  • How to include "Acknowledgements"?

    %do it as a section
  • Customize figure caption. This caption will remove "Fig.", and the separator is set as space instead of the default colon.


No comments:

Post a Comment