Latex Tips

Using braces to label parts of an equation

1
\[\Theta^+ = \underbrace{\int_0^{z_{crit}^+}\frac{dz^+}{1/Pr +\alpha_t/\nu}}_{\Romannum{1}} + \underbrace{\int_{z_{crit}^+}^{z^+}\frac{dz^+}{1/Pr +\alpha_t/\nu}}_{\Romannum{2}}\]
underbrace type

Get Roman numerals in text

  1. install the package of “romannum”

  2. type \usepackage{romannum}in the text

  3. \romannum{1} for Lowercase roman numbers or \Romannum{1} for Uppercase roman numbers

Setting ‘Fill Anywhere’ command in Latexing package in Sublime

The fill anywhere command is providing the filling that a drop down menu will let you choose what you would like to do at the current selection. For example it could be required to fill a image path somewhere else then just the normal \includegraphics command. The fill anywhere command is available for \include, \input, \subfile. \includegraphics, \ref, \cite, and \ac commands and there mutations like usual.

It is suggested to set the key binding as follows to make it handy.

1
2
3
4
5
6
7
8
{
"keys": ["ctrl+shift+alt+z"],
"command": "ltx_fill_anywhere",
"context": [
{"key": "selection_empty", "match_all": true, "operand": true, "operator": "equal"},
{"key": "selector", "operand": "text.tex.latex", "operator": "equal"}
]
}

Two statements using curly brace in an equation

1
2
3
4
5
6
7
8
9
10
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
f(x)=\begin{cases}
1, & \text{if $x<0$}.\\
0, & \text{otherwise}.
\end{cases}
\end{equation}
\end{document}
equation format
1
2
3
4
5
6
7
8
9
10
11
12
\documentclass{article}
\begin{document}
This is your only binary choices
\begin{math}
\left\{
\begin{array}{l}
0\\
1
\end{array}
\right.
\end{math}
\end{document}
equation format 2

Get information of LaTex template through command

1
2
3
4
5
6
7
8
9
\documentclass{article}
\makeatletter
\newcommand\thefont{\expandafter\string\the\font}
\makeatother
\begin{document}
\thefont % check all attributes of font
\the\columnwidth % check column width
\the\textwidth % check text width
\end{document}

Create a shortcut to the snippet palette in Sublime Text 3

add following snippet code in Preferences:Key Bindings - User

1
2
3
4
5
6
7
8
9
10
[
{
"keys": ["ctrl+y"],
"command": "show_overlay",
"args": {
"overlay": "command_palette",
"text": "Snippet: "
}
}
]

Sublime Text 3 LaTexTools configuration under Windows

The path must include `ghostscript’ to execute epstopdf. Here the path is
C:\texlive\2020\tlpkg\tlgs\bin.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
"windows": {
// Path used when invoking tex & friends; "" is fine for MiKTeX
// For TeXlive 2011 (or other years) use
"texpath" : "C:\\texlive\\2020\\bin\\win32;C:\\texlive\\2020\\tlpkg\\tlgs\\bin;$PATH",
// C:\\texlive\\2020\\tlpkg\\tlgs\\bin offer ghostgraphics path
// "texpath" : "C:\\Program Files\\MiKTeX 2.9\\miktex\\bin\\x64;PATH",
// TeX distro: "miktex" or "texlive"
//"distro" : "miktex",
"distro" : "texlive",
// Command to invoke Sumatra. If blank, "SumatraPDF.exe" is used (it has to be on your PATH)
"sumatra": "C:\\Program Files\\SumatraPDF\\SumatraPDF.exe",
// Command to invoke Sublime Text. Used if the keep_focus toggle is true.
// If blank, "subl.exe" or "sublime_text.exe" will be used.
"sublime_executable": "",
// how long (in seconds) to wait after the jump_to_pdf command completes
// before switching focus back to Sublime Text. This may need to be
// adjusted depending on your machine and configuration.
"keep_focus_delay": 0.5
},

Striketrhough in LaTex

\usepackage[normalem]{ulem} in the preamble

  1. \sout{text to be striked out} for a horizontal line through text to be striked out
  2. \xout{text to be crossed out} for many short diagonal lines crossing out the letters of the text to be crossed out

customise your own symbol in latex with TIKZ

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\newcommand{\strikeddowntriangleFilled}[1]{
\begin{tikzpicture}
\node[inner sep=0pt] (triangle) at (0,0) {
\begin{tikzpicture}
\fill[line width = #1] (0,0) -- ++(0.55em,0) -- ++(-0.275em,0.55em) -- cycle;
\end{tikzpicture}
};
\draw[line width=#1] (triangle.west) -- (triangle.east);
\end{tikzpicture}
} % this generates a filled symbol with strikethrough line

\newcommand{\dcircle}[1]{
\begin{tikzpicture}[line width=#1]
\node[inner sep=0pt,circle,minimum size=0.55em,draw] (circle) {};
\end{tikzpicture} % draw a circle with comparable size of font.
}

\DeclareRobustCommand{\crossdefined}[1]{
\begin{tikzpicture}
\node[inner sep=0pt] (cross) at (0,0) {
\begin{tikzpicture}
\draw[line width=#1] (0,0) -- (0.3525em,-0.3525em);
\draw[line width=#1] (0,-0.3525em) -- (0.3525em,0);
\end{tikzpicture}
};
\end{tikzpicture}
}

\DeclareRobustCommand{\plusdefined}[1]{
\begin{tikzpicture}
\node[inner sep=0pt] (plus) at (0,0) {
\begin{tikzpicture}
\draw[line width=#1] (0,0) -- (0.50em,0);
\draw[line width=#1] (0.275em,0.275em) -- (0.275em,-0.275em);
\end{tikzpicture}
};
\end{tikzpicture}
}

\DeclareRobustCommand{\filldowntriangle}[1]{
\begin{tikzpicture}
\node[inner sep=0pt] (triangle) at (0,0) {
\begin{tikzpicture}
\draw[fill=#1] (0,0) -- ++(0.55em,0) -- ++(-0.275em,-0.55em) -- cycle;
\end{tikzpicture}
};
\end{tikzpicture}
}

\DeclareRobustCommand{\filluptriangle}[1]{
\begin{tikzpicture}
\node[inner sep=0pt] (triangle) at (0,0) {
\begin{tikzpicture}
\draw[fill=#1] (0,0) -- ++(0.55em,0) -- ++(-0.275em,0.55em) -- cycle;
\end{tikzpicture}
};
\end{tikzpicture}
}

\DeclareRobustCommand{\uptriangle}[2]{
\begin{tikzpicture}
\node[inner sep=0pt] (triangle) at (0,0) {
\begin{tikzpicture}
\fill[line width = #1,color = #2,fill = none,draw = #2] (0,0) -- ++(0.55em,0) -- ++(-0.275em,0.55em) -- cycle;
\end{tikzpicture}
};
\end{tikzpicture}
}



add logo in the beamer

1
2
3
4
5
6
7
8
9
\setbeamertemplate{frametitle}{\vspace{6pt}\hspace{-5pt}\textbf{\insertframetitle} \hspace*{\fill}
\begin{tikzpicture}[remember picture, overlay]
\node [inner sep=0pt,
%xshift=-..., yshift=-... % if you like to shift the image out of corner
below left]
at (current page.north east) {\includegraphics[height=0.12\paperheight]{unimelb-logo.png}};
\end{tikzpicture}
\hspace{0pt}
}

using `biblatex’ to insert reference

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  \usepackage[american]{babel}
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usepackage[backend=biber,style=apa,natbib=true,sorting = ynt,sortcites = true, maxcitenames = 2, date = year, uniquename=false, uniquelist=false]{biblatex}
\DeclareLanguageMapping{american}{american-apa}
\DeclareFieldFormat{doi}{}
\DeclareFieldFormat{url}{}
\DeclareFieldFormat{issn}{}
\DeclareFieldFormat{urldate}{}
\DeclareFieldFormat{version}{}
\renewbibmacro*{doi+url+urldate+issn+version}{}

\addbibresource{referenceBitex.bib}
% Make the journaltitle field a hyperlink
\DeclareFieldFormat[article]{journaltitle}{\href{\thefield{url}}{\textnormal{#1}}}
% Remove quotation marks around titles of papers
\DeclareFieldFormat[article]{title}{#1}

using package cleveref

1
2
3
4
5
6
\usepackage[capitalize]{cleveref} 
\crefname{chapter}{Chapter}{Chapters}
\crefname{section}{Section}{Sections}
\AtBeginEnvironment{appendices}{\crefalias{chapter}{appendix}}
\crefname{figure}{Figure}{Figures}

add footnotemark in table environment

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
\begin{table}[!t]
\centering
\begin{threeparttable} % Start threeparttable environment
\caption{%
Dual-wire sensors' dimension.
}
\label{tab:dual_wireDimension}
\begin{tabular}{cccccccc}
\hline
$\alpha_{{p}}$ & $d_\mathrm{hw}$\tnote{*} & $d_\mathrm{cw}$\tnote{*} & $l_\mathrm{hw}$ & $l_\mathrm{cw}$ & $L_\mathrm{hw}$ & $L_\mathrm{cw}$ & $\Delta x$ \\
(deg) & ($\mathrm{\upmu m}$) & ($\mathrm{\upmu m}$) & ($\mathrm{mm}$) & ($\mathrm{mm}$) & ($\mathrm{mm}$) & ($\mathrm{mm}$) & ($\mathrm{mm}$) \\
$10$ & 5.0 & 1.5 & 1.36 & 1.37 & 2.0 & 3.3 & 1.6 \\
$25$ & 5.0 & 1.5 & 1.32 & 1.36 & 1.9 & 3.0 & 1.9 \\
\hline
\end{tabular}
\begin{tablenotes}[flushleft] % Start tablenotes environment with flushleft option
\item[\textsuperscript{*}] The subscript $_\mathrm{hw}$ and $_\mathrm{cw}$ denotes the quantity of hot-wire and cold-wire, respectively.
\end{tablenotes} % End tablenotes environment
\end{threeparttable} % End threeparttable environment
\end{table}
打赏
  • © 2020-2026 Yu Xia
  • Powered by Hexo Theme Ayer
    • PV:
    • UV:

Buy me a cup of coffee~

支付宝
微信