Experience with LaTex
This mainly records some of the errors I encoutered when using LaTex.
Contents
1. inkscape
According to the example file of ITMO template, to import the vector graphics, this tool must be installed. I’ve never insert any figure of this kind before.
As many other tools are installed along with TeX itself, so I searched in TeX Live Utility first. There’s a package called svg-inkscape
. On that moment I didn’t reailize that the name of a certain package will not have any other prefix on it.
I checked its description, seems alright: How to include an SVG image in LaTeX using Inkscape. Though in the documentation, the date is a little suspicious. I was 2013. And of course, when I tried to call it, errors emerged.
Through searching, so the tool works like this: it convert the svg
file into a pdf file with same name and insert it into the position.
So skipping those trials and errors, I belive this site also gives a clear tutorial.
For installing Inkscape
, I used brew
.1
brew install --cask inkscape
By default, the shell won’t call a external program, so options must be added when compiling.1
pdflatex --shell-escape file.tex
This is a direct execution, as I used LaTeX workshop
in VSCode, so settings should be changed.
Search the keyword recipe
in settings, select edit in settings.json
, with the preset, copy and modify new tools first, like this (note the comma):1
2
3
4
5
6
7
8
9
10
11{
"name": "pdflatex-escape",
"command": "pdflatex",
"args": [
"-shell-escpae",
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
},
Then adda a new recipe (just example, use what you need instead):1
2
3
4
5
6{
"name": "pdflatex (escape)",
"tools": [
"pdflatex-escape"
]
},
2. Option clash for package graphicx
Directly starts with error:
The error message is stright forward, you may look for the exact position where include this package, and change the include order, as the options have set relations. And sometimes it could be hard, as some packages will include packages that you may already defined. In my case the real package conflict are between
svg
and graphicx
.
3. Subfigure and Subfloat
Subfigure
is sort of deprecated package. As I found it first and in the first template I used, there was no conflict, so I kept using it for some semesters. Till recently in the ITMO template, it clashed. So I went for other ways around.
Forgot to mention that, subfigure has two way of implementation, the first one, as documented on over leaf, also failed in my first template. And another way, the syntax is similar to that of subfloat
, which is:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15\begin{figure}[!htb]
\hfill
\centering
\subfloat[sub label]{
\centering
\includegraphics[width=0.45\textwidth]{pic1}
}
\hfill
\subfloat[sub label]{
\includegraphics[width=0.45\textwidth]{pic2}
}
\hfill\null
\caption{ }
\label{}
\end{figure}
And another thing is that engine automatically ingore the spaces at the end, so only adding \hfill
will not make a difference, \null
must be added behind it.