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
\hypersetup{%
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
\makeatletter
\newcommand*\bibhyphen{\hbox{-}\nobreak\hskip\z@skip}
\makeatother
\newcommand*\bibdash{\rule[0.48ex]{2em}{0.14ex}\space}
-
How to add bibliography to the table of contents?
\usepackage[nottoc]{tocbibind} %add bibliography to toc
-
How to use "bibliography" instead of "references"?
\renewcommand{\refname}{Bibliography}
-
How to enlarge margin paragraph width without using geometry
package since it rewrites all the default layout values?
%set twice as default
\setlength{\marginparwidth}{2\marginparwidth}
-
How to center texts?
%maybe you are looking for \vspace{2cm} too?
\begin{center}
This is centered text.
\end{center}
-
How to give remarks in red?
\usepackage{color}
%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.
\usepackage{CJK}
\begin{CJK}{UTF8}{bkai}
漢字
\end{CJK}
%to merge CJK with another environment, embed that environment within CJK, such as
\begin{CJK}{UTF8}{bkai}
\marginpar{
丁香
}
\end{CJK}
-
An example of including a centered figure with caption and label.
\usepackage{grahpicx}
\begin{figure}[ht]
\centering
\includegraphics{pic.jpg}
\caption{sample picture}
\label{fig:sample-pic}
\end{figure}
-
How to put two pictures side by side with each of its own caption and label?
\usepackage{subfigure}
\begin{figure}[ht]
\centering
\subfigure[Caption a]{
\includegraphics[width=.45\linewidth]{img1.png}
\label{fig:imga}
}
\hspace{.2in}
\subfigure[Caption b]{
\includegraphics[width=.45\linewidth]{img2.png}
\label{fig:imgb}
}
\caption{Two figures}%
\label{fig:2-fig}
\end{figure}
-
How to introduce plain codes?
\usepackage{verbatim}
\begin{verbatim}
int sched_setscheduler(pid_t pid, int policy,
const struct sched_param *param);
\end{verbatim}
-
How to include "Acknowledgements"?
%do it as a section
\section*{Acknowledgements}
\addcontentsline{toc}{section}{Acknowledgements}
-
Customize figure caption. This caption will remove "Fig.", and the separator is set as space instead of the default colon.
\renewcommand{\figurename}{}
\usepackage[labelsep=space]{caption}