当前位置:网站首页>Latex learning

Latex learning

2022-07-06 12:23:00 Wang Xiaoxi WW

Latex Study

List of articles

One 、TeX,LaTeX,MikTex,CTeX,TeX Live What is it and its difference

This blog is based on FAQ The mode of TeX What is it? : Wang Yin introduced TeX, A professional typesetting system , It can be roughly understood as using comparison word、pdf What you see is what you get ,TeX It's a typesetting system , Use code to write , Leave the typesetting work to the program , Achieve what you want is what you get ,TeX It is very suitable for scientists to write academic papers and books , For example, the input of formula will be better than word Much more convenient .
TeX,LaTeX,MikTex,CTeX,TeX Live And so on, many versions look very confusing , Actually sum linux The various versions of are a bit like , Their macros are a little different .
Knuth Created TeX after , It's free TeX The source code of the program . So anyone can compile that file into a program without modifying it , Then it is packaged and distributed with many other programs . So there are many distributions , such as Windows There are MikTeX,fpTeX etc. , and Linux and UNIX There are teTeX. These abbreviations “ issue ”.
TeX and MikTeX,teTeX The relationship between etc. , It's like Linux and Debian GNU/Linux, RedhatLinux The relationship between etc. . every last TeX The release includes TeX, METAFONT,LaTeX, amsTeX, MetaPost, dvips, pdfTeX, dvipdfm Wait for every Linux The distribution includes Linux kernel ,bash, gcc, tar, XFree86 wait .
So which one to install ?
although CTeX in MiKTeX Too old , Unable to update macro package solution The problems described in this blog have not been encountered , And compared with this blog, the official website version has been updated , But it is still not recommended to use minimal installation ( I have come to modify my blog ).
win Next TeX Live The default is full installation , and MikTeX The default is to minimize installation , When you really use it ,MikTeX There will be all kinds of errors due to the lack of all kinds of things , The so-called use of bags and then on the spot can not solve a lot error, So it is recommended to install the full version TeX Live, One step in place .
MikTeX、TeX Live And so on are compilation environments ,TexStudio、TexMaker Wait for the compiler ( It should be an integrated development environment ) ( compiler ?? Compile environment ?? Isn't it a thing ? You can refer to C/C++ The compiler | Compile environment ( A very comprehensive comparison ))

Reference resources LaTex+TexStudio Environment configuration

Two 、TexLive Installation and environment configuration

1、VSCode+Texlive+SumatraPDF build Latex Environmental Science (***)

1)Texlive Installation and environment configuration of

2)vscode(Latex workshop) + setting To configure ( The main settings are what to compile :xelatex,pdflatex, still bibtex)

3)sumapdf install , Realization Forward search / Reverse search ( Here is a bug, You need to open it first sumapdf, can Reverse index , Forward index use ctrl+alt+J

​ Reference resources b standing up Sharing of the Lord :Win10+VSCode+Texlive+SumatraPDF build Latex Environmental Science That's enough

problem : Compilation ratio CTEX Chinese suit is hard

2、Texlive Install macro package

Reference resources windows Under the TeX Live How to install downloaded sty Macro package ?

3、 ... and 、MikTex install

1、MikTex install

CTeX Chinese suit Is based on Windows Under the MiKTeX System , Integrated editor WinEdt and PostScript Processing software Ghostscript and GSview And other major tools . among CTeX An important function of is to realize TeX Documentation and PDF Forward and reverse search between files , It is commonly called mutual jump . This is very useful and convenient for daily writing and revision .

Reference resources https://cloud.tencent.com/developer/news/727675

Installation tutorial reference CTex+WinEdt10.2 Install detailed tutorials and cracking ( Fool installation , Click next )

I installed CTeX_2.9.2.164_Full.exe edition (1.3G, contain MikTeX,winEdt,sumtrapdf). Tsinghua mirror website :https://mirrors.tuna.tsinghua.edu.cn/ctex/legacy/2.9/

MikTex Environment variable configuration path = F:\latex\CTEX\MiKTeX\miktex\bin , If the system is also installed Texlive, And configured path, Suggest set priority .

cmd >> tex --version verification

2、winEdt Use (*****)

1) Compile environment settings

Q: If MikTex The environment variable is not set correctly , Or say It was used Tex Live Environment variables of , be winEdt The compile button above will not recognize Compile the file (eg,pdflatex.exe,textify.exe), all Show gray

resolvent :

  • Options >> Execution Mode, see Full Executable In that column exe Whether the file really exists .
  • If it doesn't exist , Reconfiguration MikTex environment variable , restart winEdt, When you open it again ,winEdt I will go to the automatic identification system latex Environment variables of ( I used to use texlive environment variable , Lead to winEdt The compile buttons are all gray )
  • I remember MikTex Multiple environment variables should be configured , But I only configured path = F:\latex\CTEX\MiKTeX\miktex\bin, Most compiled files can be used (pdfTexify.exe It can be used ), A few of them can't be used (dvi2pdf Unavailable , So insert pictures later with jpg, no need eps, because eps Need to pass through dvi2pdf Compile )
2) Forward and reverse indexing

Reference resources Latex Winedt+SumatraPDF The reason why reverse search cannot ,WinEdt And SumatraPDF Forward and reverse search function

  • Pay attention to opening --src, First dvi2pdf, Again pdfTexify,winedt Of pdf Search It will light up
  • Forward index : Left click the mouse cursor TeX Somewhere in the source code of the document , Then left click “PDF Search” Button
  • Reverse index : Build... In compilation PDF after , stay PDF Double click a line on the page , You can jump to TeX The corresponding source code of the document ( If the reverse index doesn't respond , Then open SumatraPDF, Click again winedt Of pdf Search

After configuration , Compile the file , You will see a folder :xxx.synctex.gz, Mainly for Save forward and reverse index information .

3) Master file settings

stay winEdt The last column in the bottom column , Sure Specify the current project location , With tex The master document shall prevail , Load the current directory structure .( If... Cannot be set , The click WinEdt.prj That column is enough )

 Insert picture description here

next ,View >> Tree Show tex Article structure , If it already exists , First Delete the current Tree, Refresh You can get the new project tex Tree

5、 ... and 、Latex skill

1、 fit LaTeX Beginner's blog

2、 Circled numbers and list of circled numbers

Reference resources LaTeX skill 775: Circled numbers and list of circled numbers

\usepackage{tikz}
\newcommand*{\circled}[1]{\lower.7ex\hbox{\tikz\draw (0pt, 0pt)%
    circle (.5em) node {\makebox[1em][c]{\small #1}};}}
\robustify{\circled}    

\circled{20}  # Circled number 20
\documentclass{article}
\usepackage{tikz}
\usepackage{etoolbox}
\usepackage{enumitem}
\newcommand*{\circled}[1]{\lower.7ex\hbox{\tikz\draw (0pt, 0pt)%
    circle (.5em) node {\makebox[1em][c]{\small #1}};}}
\robustify{\circled}
\begin{document}
\mbox{}\rlap{\rule{.7\linewidth}{.4pt}}%
This is the circled number \circled{20}.

\begin{enumerate}[label=\circled{\arabic*}]
\item I
\item am
\item happy
\item to
\item join
\item with
\item you
\item today
\end{enumerate}
\end{document}

3、 Insert hyperlink

Reference resources Latex course : [10] Insert hyperlink

# Add macros to the document header 
\usepackage[colorlinks,linkcolor=red]{hyperref}

\url{www.baidu.com} # Insert hyperlink 

If Do not want to appear in the body of the link address Words , And want to use text or other fonts to display links , You can enter the following code :

\href{www.baidu.com}{ Baidu }

4、 Insert a picture + notes

1) Insert a picture

Reference resources LaTeX Several common methods of inserting pictures into documents

  • If it is eps The graphic , The compilation process is latex, dvips, ps2pdf.

  • If it is pdf jpg png graphics , The compilation process is pdflatex .

Reference resources Latex In the illustration summary ( One )

\usepackage{graphicx}

\centerline{\includegraphics[scale=0.6]{example/eeg.jpg}} # Insert a picture 
\centerline{\fontsize{26pt}{26pt} EEG The signal }  # Insert a picture comment ( This is not recommended )

Be careful jpg The suffix of the picture is Capitalization ’JPG’,dvi2pdf -> pdfTextify Will be displayed normally

2) Photo caption

Reference resources LaTex Insert pictures side by side , And note the description under each picture

\begin{figure}[t]
\centering
    \begin{tabular}{cc}
        \begin{minipage}[t]{3in}
        \includegraphics[width=2.8in]{example/eeg.jpg}
        \caption{EEG The signal .}
        \end{minipage}
    %%
        \begin{minipage}[t]{3in}
        \includegraphics[width=2.8in]{example/eeg.jpg}
        \caption{EEG The signal .}
        \end{minipage}
    \end{tabular}
\end{figure}

 Insert picture description here

5、 Change the font

Reference resources use fontsize To modify the font of the text

6、 Insert sequence table

\begin{enumerate}
	\item  This is a sequential list .
	\item  This is a sequential list .
	\item  This is a sequential list .
\end{enumerate}

7、 Insert unordered list

\begin{itemize}
	\item  This is an unordered list .
	\item  This is an unordered list .
	\item  This is an unordered list .
\end{itemize}

8、 Refer to the website and footnotes

 Reference database (thesis.bib) The entry of , It can be downloaded from Google Scholar Search engine \footnote{\url{https://scholar.google.com}}、CiteSeerX Search engine \footnote{\url{http://citeseerx.ist.psu.edu}} Search for , Document management software Papers\footnote{\url{http://papersapp.com}}、Mendeley\footnote{\url{http://www.mendeley.com}}、JabRef\footnote{\url{http://jabref.sourceforge.net}}  It can also output item information .

 Insert picture description here

Be careful :\url{} Cannot process with ’’ % \% %" Link to ( It's not good to bring a translation symbol ), and \href{} Sure .

\href{https://baike.baidu.com/item/%E5%80%92%E8%B0%B1/9851556?fr=aladdin}{ Baidu Encyclopedia : cepstrum }

9、 Draw table

1) The form basically uses

Reference resources LaTeX Insert table

Note:l Align left ,c Align in the middle ,r Align right

\begin{table}[]
    \caption{basic structure}
    \vspace{20pt}
    \centering
    \begin{tabular}{lllll}
        \hline
        \thead[l]{Gene\\name} & \thead[l]{Gene accession\\No. }& \thead[l]{CDS length\\(bp)} & \thead[l]{Protein size\\(aa)} & \thead[l]{Protein MW\\(kDa)} \\
        \hline
        001  & 01g009860.2   & 819             & 272               & 31.34            \\
        002  & 01g021730.2   & 798             & 265               & 30.37            \\
        003  & 01g094490.2   & 630             & 209               & 24.58            \\
        004  & 01g102740.2   & 1242            & 413               & 46.94            \\
        005  & 01g104900.2   & 597             & 198               & 22.85            \\
        006  & 02g036430.1   & 1698            & 565               & 64.88            \\
        007  & 02g061780.2   & 735             & 244               & 28.23            \\
        008  & 02g061870.1   & 660             & 219               & 25.21            \\
        009  & 02g061900.1   & 915             & 304               & 34.61            \\
        010  & 02g061910.1   & 795             & 264               & 29.92 \\    
        \hline       
    \end{tabular}
    \abel{bs}
\end{table}
2) Table too wide and too narrow adjustment

What if the form is too wide ? Reference resources Latex The table is too large ( Or too small ) Adjustment method of

\begin{center}
\textbf{Table 1}~~Original table.\\
\resizebox{\textwidth}{15mm}{
\begin{tabular}{cccccccccccc} \toprule
Models  &  $\hat c$  &  $\hat\alpha$  &  $\hat\beta_0$  &  $\hat\beta_1$  &  $\hat\beta_2$ & Models  &  $\hat c$  &  $\hat\alpha$  &  $\hat\beta_0$  &  $\hat\beta_1$  &  $\hat\beta_2$  \\ \hline
model  & 30.6302  & 0.4127  & 9.4257  & - & -  & model  & 30.6302  & 0.4127  & 9.4257  & - & -\\
model  & 12.4089  & 0.5169  & 18.6986  & -6.6157  & - & model  & 30.6302  & 0.4127  & 9.4257  & - & - \\
model  & 14.8586  & 0.4991  & 19.5421  & -7.0717  & 0.2183 & model  & 30.6302  & 0.4127  & 9.4257  & - & - \\
model  & 3.06302  & 0.41266  & 0.11725  & - & - & model  & 30.6302  & 0.4127  & 9.4257  & - & - \\
model  & 1.24089  & 0.51691  & 0.83605  & -0.66157  & - & model  & 30.6302  & 0.4127  & 9.4257  & - & - \\
model  & 1.48586  & 0.49906  & 0.95609  & -0.70717  & 0.02183  & model  & 30.6302  & 0.4127  & 9.4257  & - & - \\
\bottomrule
\end{tabular}}
\end{center}
3) Table merging and splitting

Reference resources Latex Summary of some table usage in ( Two )—— Determinant table , Segmentation and merging of tables

Merge of columns :

Note:\multicolumn{ Merge Columns }{ New column format }{ Content }

\documentclass[UTF8]{ctexart}

\begin{document}

\begin{tabular}{|c|c|c|}
\hline
\multicolumn{2}{|c|}{ achievement }  \\ \hline
 Chinese language and literature   &    mathematics   \\   
\hline

87    & 100  \\
\hline

\end{tabular}


\end{document}

 Insert picture description here

Consolidation of rows :

Note:\multirow{ Number of merged rows }{ New column format }{ Content }, Note the introduction of macro packages \usepackage{multirow}

\documentclass[UTF8]{ctexart}
\usepackage{multirow}
\begin{document}

\begin{tabular}{|c|r|r|}
\hline
\multirow{2}*{ full name } & \multicolumn{2}{c|}{ achievement }  \\ \cline{2-3}
                    &   Chinese language and literature   &    mathematics   \\   
\hline

             Zhang San     & 87    &  100 \\
\hline

\end{tabular}

\end{document}

 Insert picture description here

4) Center the table as a whole

Reference resources Latex Center the table as a whole

5) Table generation tool

Table generation tool :Table Generator, Strongly recommended , The merging and splitting of tables is very convenient , Style modification is also more convenient ( In the middle , Size ).

10、 Formula numbering and alignment

Reference resources latex The formula 、 Number 、 alignment

Single formula :

\begin{equation}
\ Formula code ( Example :Omega\left(f_{t}\left(X_{i} ; \theta\right)\right)=\gamma T+\frac{1}{2} \lambda\|w\|^{2})
\end{equation} 

Multiple formulas :

\begin{eqnarray}
PERCLOS = \frac{\sum(T_6 - T_5) }{T_2 - T_1} \\ 
p = e + 0.2 * (m - e)
\end{eqnarray}

Go to number :

\begin{align}
& \tilde s_i^2 = w^T S_i w \\
& \tilde s_1^2 + \tilde s_2^2 =  w^T S_w w
\end{align}

Note:

  • Don't write in blank lines , Otherwise, an error will be reported

  • stay \{equation} or \{eqnarray} There is no need to $..$

  • You can modify the default number

  • If there is Chinese in the formula , use \mbox{xxx}

    P\{\mbox{ Refuse } \mid H_{0} \mbox{ It's true }\} = \alpha
    

    KaTeX parse error: Undefined control sequence: \mbox at position 5: P\{\̲m̲b̲o̲x̲{ Refuse } \mid H_{0}…

11、Tikz mapping

%# -*- coding: utf-8-unix -*-
\thispagestyle{empty}
\begin{tikzpicture}[overlay,remember picture,font=\sffamily\bfseries]
\draw[ultra thick,c4,name path=big arc] ([xshift=-2mm]current page.north) arc(150:285:11)
coordinate[pos=0.225] (x0);
\begin{scope}
\clip ([xshift=-2mm]current page.north) arc(150:285:11) --(current page.north
east);
\fill[c4!50,opacity=0.25] ([xshift=4.55cm]x0) circle (4.55);
\fill[c4!50,opacity=0.25] ([xshift=3.4cm]x0) circle (3.4);
\fill[c4!50,opacity=0.25] ([xshift=2.25cm]x0) circle (2.25);
\draw[ultra thick,c4!50] (x0) arc(-90:30:6.5);
\draw[ultra thick,c4] (x0) arc(90:-30:8.75);
\draw[ultra thick,c4!50,name path=arc1] (x0) arc(90:-90:4.675);
\draw[ultra thick,c4!50] (x0) arc(90:-90:2.875);
\path[name intersections={of=big arc and arc1,by=x1}];
\draw[ultra thick,c4,name path=arc2] (x1) arc(135:-20:4.75);
\draw[ultra thick,c4!50] (x1) arc(135:-20:8.75);
\path[name intersections={of=big arc and arc2,by={aux,x2}}];
\draw[ultra thick,c4!50] (x2) arc(180:50:2.25);
\end{scope}
\path[decoration={text along path,text color=c4,
	raise = -2.8ex,
	text  along path,
	text = {|\sffamily\bfseries|\today},
	text align = center,
},
decorate
] ([xshift=-2mm]current page.north) arc(150:245:11);
%
\begin{scope}
\path[clip,postaction={fill=c3}]
([xshift=2cm,yshift=-8cm]current page.center) rectangle ++ (4.2,7.7);
\fill[c2] ([xshift=0.5cm,yshift=-8cm]current page.center)
([xshift=0.5cm,yshift=-8cm]current page.center)  arc(180:60:2)
|- ++ (-3,6) --cycle;
\draw[ultra thick,c4] ([xshift=-1.5cm,yshift=-8cm]current page.center)
arc(180:0:2);
\draw[ultra thick,c4] ([xshift=0.5cm,yshift=-8cm]current page.center)
arc(180:0:2);
\draw[ultra thick,c4] ([xshift=2.5cm,yshift=-8cm]current page.center)
arc(180:0:2);
\draw[ultra thick,c4] ([xshift=4.5cm,yshift=-8cm]current page.center)
arc(180:0:2);
\fill[red] ([xshift=2.5cm,yshift=-8cm]current page.center) +(60:2) circle(1.5mm);
\node[text=c5!80!black] at ([xshift=4.7cm,yshift=-5.2cm]current page.center) {$\rho:=\dfrac{1+\sqrt{-3}}{2}$};
\end{scope}
%
\fill[c1] ([xshift=2cm,yshift=-8cm]current page.center) rectangle ++ (-13.7,7.7);
\node[text=white,anchor=west,scale=4,inner sep=0pt] at
([xshift=-10.55cm,yshift=-3cm]current page.center) {$\mathbb{ Q }$-book  Book templates };
\node[text=white,anchor=west,scale=2,inner sep=0pt] at
([xshift=-4.5cm,yshift=-5.5cm]current page.center) {333 \quad  Make };
\end{tikzpicture}

 Insert picture description here

Suggest :

  • It is recommended to use overleaf, You can view the effect in real time , After downloading Save as pdf, As Image import that will do ( no need svg, It's still clear ).overleaf

  • It is not recommended to use \input,\include Nested with tikz Of .tex file , Easy to compile errors ( It is likely to change the original code format , Want to restore the original compilation , You will also report mistakes. ).

    • \documentclass{standalone} and \documentclass{book} Conflict

    • pdfTexify from compile 1 The next change is 3 Time , Now I Leave only tex Master file See if you can change bug, It turns out that bug It's not solved , In the end Compilation failed (700 individual error), There is a coding format conversion that I haven't seen before :gbk2uni. The solution is to download the template again , Paste and copy the source code ( The main reason is xxx.cls The file cannot be deleted , Lord tex You will not find the style latex Of cls Document instructions ).
       Insert picture description here

Reference resources

12、latex Multi file integration

Reference resources Latex Multi file integration

13、 Add algorithm table

Reference resources

1) English Algorithm 1

Import two packages :\usepackage{algorithmic},\usepackage{algorithm}

\documentclass[]{book}  
%\usepackage[UTF8]{ctex}  % If you don't add it, you can't display Chinese normally 
\usepackage{algorithmic}
\usepackage{algorithm}
%\floatname{algorithm}{ Algorithm }
%\renewcommand{\algorithmicrequire}{\textbf{ Input :}}
%\renewcommand{\algorithmicensure}{\textbf{ Output :}} 
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}

\begin{document}
\begin{algorithm}[]
\caption{ Algorithm Algorithm Algorithm Algorithm}
\label{alg:Framwork}
\begin{algorithmic}[] % This 1  Indicates that each line displays a number 
\REQUIRE ~~\\ % Input parameters of the algorithm :Input
Secret bit stream: B={0100……}\\
Embedding rate: m bit\\

\ENSURE ~~\\ % The output of the algorithm :Output
Multiple sentences: Text;
\IF {not the end of current sentence}
\STATE Calculate the probability distribution of the next word ;
\STATE \STATE Calculate the perplexity of the words generated with the word of CP;
\IF {$ppl_j$ less than ppl}
\STATE Select the word to form the CP\_new;
\IF {CP\_new is empty}
\STATE Selected the word which has the highest conditional probability in the CP;
\ELSE
\STATE Construct a Huffman tree according to the probability distribution of each word in the CP\_new and encode the word;
\ENDIF
\ENDIF
\ELSE
\STATE Random pick a word from start word list start the other sentence;
\ENDIF
\RETURN generated sentences; % The return value of the algorithm 
\end{algorithmic}
\end{algorithm}
\end{document}
2) English Algorithm 2

Reference resources

Import a package :\usepackage[options]{algorithm2e}

\documentclass[]{book}
\usepackage[ruled,vlined]{algorithm2e}

\begin{document}
\begin{algorithm}[t]
	\caption{Framework of Meta-GNN.}
	\label{alg:algorithm1}
	\KwIn{Distribution over mete-training tasks: $p(\mathcal{T})$; Meta-testing tasks: $\mathcal{T}_{mt}$; Task-learning rate: $\alpha_{1}$; Meta-learning rate: $\alpha_{2}$.}
	\KwOut{Labels of nodes in query set of $\mathcal{T}_{mt}$.}
	\BlankLine
	Initialize $\bm{\theta}$ randomly;
	
	\While{\textnormal{not converged}}{
		Sample batch of meta-training tasks $\mathcal{T}_{i} \sim p(\mathcal{T})$;
		
		\ForEach{task in $\mathcal{T}_{i}$}{
			Evaluate $\mathcal{L}_{\mathcal{T}_{i}}\left(f_{\bm{\theta}}\right)$ using $\mathcal{S}_{i}$;
			
			Compute adapted parameters $\bm{
   {\theta}^{\prime}_{i}}$;
			
			Evaluate $\mathcal{L}_{\mathcal{T}_{i}}\left(f_{\bm{
   {\theta}_{i}^{\prime}}}\right)$ using $\mathcal{Q}_{i}$;
		}
		Update $\bm{\theta}$ by;
	}
	
	Compute adapted parameters $\bm{
   {\theta}^{\prime}_{mt}}$ using support set of $\mathcal{T}_{mt}$;
	
	Predict labels of nodes in query set of $\mathcal{T}_{mt}$ using model $f_{\bm{
   {\theta}_{mt}^{\prime}}}$.
\end{algorithm}
\end{document}

 Insert picture description here

3) Chinese Algorithm 1

Reference resources

stay **“1) English Algorithm 1”** Based on the addition of :

%\documentclass[UTF8]{ctexart} % obsolete , Out-of-service 

\documentclass[]{book}  
\usepackage[UTF8]{ctex}  % If you don't add it, you can't display Chinese normally 

\floatname{algorithm}{ Algorithm }
\renewcommand{\algorithmicrequire}{\textbf{ Input :}}  % Add new instruction 
\renewcommand{\algorithmicensure}{\textbf{ Output :}}

 Insert picture description here

4) Chinese Algorithm 2(*****)

Reference resources utilize alogrithm2e An algorithm overview of typesetting

%\renewcommand{\algorithmcfname}{ Algorithm }  % Don't take effect 
\floatname{algorithm}{ Algorithm } % take effect 
\SetKw{KwInput}{\textbf{ Input :}}{}
\SetKw{KwOutput}{\textbf{ Output :}}{}
\begin{algorithm}[H]
\SetAlgoLined
\KwInput{ Training data set $D$ And characteristics $A$} \\
\KwOutput{ features A On the training data set $D$ Information gain of $g(D,A)$ } \\
(1)  Computational data set D The experience of the entropy $H(D)$ \\
\begin{array}{c}
\quad \quad H(D) = - \sum_{k=1}^{K} \frac{|C_k|}{|D|}log_2\frac{|C_k|}{|D|}
\end{array}

(2) Calculating characteristics A The data set D Entropy of empirical conditions $H(D|A)$ \\
\begin{array}{c}
\quad \quad H(D|A)= \sum_{i=1}^{n} \frac{|D_i|}{|D|}H(D_i) = -\sum_{i=1}^n \frac{|D_i|}{|D|} \sum_{k=1}^K \frac{|D_{ik}|}{|D_i|}log_2\frac{|D_{ik}|}{|D_i|}
\end{array}

(3) Calculated information gain  \\
\begin{array}{c}
\quad \quad g(D|A) = H(D) - H(D|A)
\end{array}
\caption{ Information gain algorithm }
\end{algorithm}

 Insert picture description here

5) Problem solving (*****)

For the first method : Import \usepackage{algorithmic},\usepackage{algorithm} English Algorithm 1

Some packages may be introduced during clssty File conflict ( such as \usepackage[UTF8]{ctex}), The format cannot be displayed normally , The solution is to create another tex( Best in main.tex subdirectory , Easy to manage ), After drawing the algorithm table , Import into main.tex In file .

 Insert picture description here

For the second method : Import \usepackage[options]{algorithm2e}, The format is displayed normally . English Algorithm 2

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-u8J4hSM8-1644548791917)(./img/Snipaste_2021-03-30_11-54-36.jpg)]

14、latex Insert gif Moving graph

Latex Using skills : Insert .gif Animation

First the gif The moving picture is converted into multiple png-24 Pictures of the ( use PS Export all layers to a file )

Use :

  • introduce animate Macro package :\usepackage[<options>]{animate}

  • We must first introduce graphicx Macro package

  • \animategraphics[<options>]{<frame rate>}{<file basename>}{<first>}{<last>}
    

In the end, it failed , The image doesn't move , Give up the struggle .

 Insert picture description here

15、 Add code

Reference resources

\begin{lstlisting}[language={C}, caption={PCA Model python Realization }]
##Python Realization PCA
import numpy as np
def pca(X,k):#k is the components you want
  #mean of each feature
  n_samples, n_features = X.shape
  mean=np.array([np.mean(X[:,i]) for i in range(n_features)])
  #normalization
  norm_X=X-mean
  #scatter matrix
  scatter_matrix=np.dot(np.transpose(norm_X),norm_X)
  #Calculate the eigenvectors and eigenvalues
  eig_val, eig_vec = np.linalg.eig(scatter_matrix)
  eig_pairs = [(np.abs(eig_val[i]), eig_vec[:,i]) for i in range(n_features)]
  # sort eig_vec based on eig_val from highest to lowest
  eig_pairs.sort(reverse=True)
  # select the top k eig_vec
  feature=np.array([ele[1] for ele in eig_pairs[:k]])
  #get new data
  data=np.dot(norm_X,np.transpose(feature))
  return data

X = np.array([[-1, 1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])

print(pca(X,1))
\end{lstlisting}

 Insert picture description here

Although the code is not highlighted , But at least there is no error ( If you will language={C} Change to language={python}, Compile and report errors )

Note:

  • Sure Put the code in a folder , stay tex Just quote from

    \lstinputlisting[
        style       =   C,
        caption     =   {\bf LDA.py},
        label       =   {LDA.py}
    ]{./code/LDA.py}
    

16、latex References are cited

Reference resources LaTeX skill 873: Use BibTeX Generate a list of references

bibtex Processing flow ( Depend on xelatex Generated aux file ):

 Insert picture description here

%name.bib
@mastersthesis{123a,
  title={ Research on voiceprint recognition algorithm based on deep learning },
  author={ Guo Minghan },
  year={2020},
  school={ Jilin University }
}

%document.tex
\documentclass{article}
\bibliographystyle{plain}

\begin{document}
    1231\cite{123a}
    \bibliography{name}
\end{document}

stay overleaf It's normal on the screen ( Can't display Chinese ), But in winEdt Compile time problems :

1) problem 1:\citation,\bibstyle,\bibdata not found
I found no \citation commands---while reading file voiceRecognition.aux
I found no \bibdata command---while reading file voiceRecognition.aux
I found no
\bibstyle command---while reading file voiceRecognition.aux
---
I found no \citation commands I found no \bibdata command I found no
\bibstyle command

The main reason is that two tags are not introduced \bibliographystyle,bibliography, These two labels will be BibTex Compile separately become \bibstyle,\bibdata, write in aux file .

%name.bib
\bibliography{name}
\bibliographystyle{plain}

But with it , according to latex >> bibtex >> latex >> latex Compile order of , It still doesn't work

 Insert picture description here

Online said , hold aux,bbl Wait until the intermediate generation file is deleted and then run , Reference resources latex error Ifound no \bibdata command-while~ I found no \bibstyle comman-, But it didn't work .

2) problem 2:pdf Content ,reference Display exception
%name.bib
@mastersthesis{123a,
  title={ Research on voiceprint recognition algorithm based on deep learning },
  author={ Guo Minghan },
  year={2020},
  school={ Jilin University }
}

@article{ren2015faster,
  title={Faster r-cnn: Towards real-time object detection with region proposal networks},
  author={Ren, Shaoqing and He, Kaiming and Girshick, Ross and Sun, Jian},
  journal={arXiv preprint arXiv:1506.01497},
  year={2015}
}


%document.tex
\documentclass{article}
\begin{document}
    \include{tex/chapter1}
    wang\cite{123a}
    faster-rcnn\cite{ren2015faster}
    \bibliographystyle{alpha}
    \bibliography{name}
\end{document}

bibtex Can recognize aux file :

 Insert picture description here

pdf The content cannot be displayed normally ( The compilation order is :pdflatex >> bibtex >> pdflatex >> pdflatex, I guess the main reason is qbook Class not recognized )

 Insert picture description here

References show that there are also problems , Can't show Chinese .

 Insert picture description here

3) see log file , Prompt with biber replace bibtex
Package biblatex Warning: Please (re)run Biber on the file:
(biblatex)                voiceRecognition
(biblatex)                and rerun LaTeX afterwards.
4) Final solution : Use biber.exe(*****)

Reference resources Biblatex with Biber: Configuring my editor to avoid undefined citations(https://tex.stackexchange.com/questions/154751/biblatex-with-biber-configuring-my-editor-to-avoid-undefined-citations/154755#154755) that will do .

Mainly take bibtex Compilation of bibtex.exe Modified into biber.exe( The specific location of the document is eveything Search for )

 Insert picture description here

Compile order :pdflatex >> bibtex >> pdflatex >> pdflatex

 Insert picture description here
/>

%\documentclass{article}
%\begin{document}
%    \include{tex/chapter1}
%    
%\end{document}

%# -*- coding: utf-8-unix -*-
%======================================================================
% qbook.tex for Qbook Template
%======================================================================
%  Two sided printing 
\documentclass{qbook}
\bibliographystyle{plain}
\bibliography{name,bib/qbook.bib}
\usepackage[colorlinks,linkcolor=red,anchorcolor=blue,citecolor=green]{hyperref}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{tikz}
\newcommand*{\circled}[1]{\lower.7ex\hbox{\tikz\draw (0pt, 0pt)%
    circle (.5em) node {\makebox[1em][c]{\small #1}};}}
\robustify{\circled}
\mbox{}\rlap{\rule{.7\linewidth}{.4pt}}%
\addbibresource{bib/qbook.bib}  %  Import reference database 
\begin{document}
\pagestyle{empty}
\include{tex/cover}  %  Load cover 
\begin{center}
	\Large{\sffamily\bfseries\heiti Version 2.00} \\ \vspace{2em}
	\Large{\sffamily\bfseries\heiti  Compile date : \today} \\ \vspace{1em}
	\Large{\sffamily\bfseries\heiti  Please send any suggestions and error messages to email } \\
	\texttt{[email protected]}
\end{center}
\vfill
\vspace{30em}
\begin{tabular*}{\textwidth}{ccc}
	\includegraphics{figure/by-nc.eps}
	& \begin{minipage}[b]{0.6\textwidth}
		\small\sffamily
		 This work adopts knowledge sharing   A signature - Noncommercial use  4.0  The international   License agreement to license .  visit \url{http://creativecommons.org/licenses/by-nc/4.0/  } View the license agreement .
	\end{minipage}
\end{tabular*}
\thispagestyle{empty}
\frontmatter  %  Use Roman numerals as page numbers for preface and overview 
\pagestyle{empty}
\include{tex/preface}
\pagestyle{empty}
\tableofcontents
\cleardoublepage
\include{tex/overview}
\mainmatter	  %  Use Arabic numerals as page numbers for the text 
%======================================================================
%  Text content 
\pagestyle{fancy}
\setcounter{page}{0}
\include{tex/chapter1}
\include{tex/chapter2}
\include{tex/chapter3}
\include{tex/chapter4}
\include{tex/chapter5}
%\include{tex/chapter6}
%\include{tex/chapter7}
%\include{tex/chapter8}
%\include{tex/chapter9}
%\include{tex/chapter10}
\backmatter	
%======================================================================
%  Print references 
\printbibliography[heading=bibintoc]
    wang\cite{123a}
    faster-rcnn\cite{ren2015faster}
\makeatletter
\makeatother
\end{document}

 Insert picture description here

5) Chinese references are garbled

 Insert picture description here

resolvent : modify .bib The file encoding format is utf-8,bibtex Three important sentences are as follows :

\bibliographystyle{plain} % Set reference style 
\bibliography{name,bib/qbook.bib}  % Introduce references .bib
\printbibliography[heading=bibintoc] % Print references ( Only those with references will be printed )
6)CNKI nothing Bibtex Document export format

Reference resources How to use BibTeX Cite Chinese references ? - Vopaaz Answer - You know

  • 1、 stay Python Download and install on the official website Python
  • 2、 stay Python Enter in the root directory script Folder , function cmd, perform “pip install cnki2bib”, You can install this small application exe Program
  • 3、 take cnki2bib Set to on .net Default procedure for suffix references
  • 4、 open .net Suffixed references can be generated .bib References to
7) Reference material

biber and bibtex The difference between !!

6、 ... and 、 Problem summary

1、 If tex The file reported an error during compilation , however But it can generate and update pdf file , You can ignore this error report .

2、 Be careful ,latexmk The default is to use pdflatex compile . If you want to use Chinese, be sure to set Encoded as UTF8, Otherwise, it cannot be compiled successfully . If you want to change xelatex, You need to add -xelatex.

3、winedt Cannot be opened tex file :WinEdt 6 ( Abreast of the times CTeX 2.9.2.164 Matching version ) The default in accordance with the ANSI Code on .tex file , So you need to make it open UTF8 Coded .tex file . Reference resources WinEdt Cannot be opened .tex The solution of the document

4、pdflatex Can't identify .eps File format , Garbled : Reference resources CTex Load in EPS The problem with the picture ——pdflatex Can't identify .eps File format

terms of settlement :

  • Law 1、 Can be eps The file is converted to pdf picture , or jpg,jpeg picture , or png picture ..∵pdflatex Only know this 4 There are three formats of pictures .
  • Law 2、 Use latex Convert to dvi Format , Then through the program will dvi Convert to pdf, There are two ways , All through DOS Command line :

5、Latex Use

  • 1、latex,tex,xelatex,pdflatex,latexmk The difference between ( Don't study what to compile , Just use it )
  • 2、latex Sub file compilation
  • 3、vscode To write latex Plug in for
  • 4、 Why some latex project (ctex) Can't compile , Always reporting mistakes

6、 It is not recommended to use \input,\include Nested with tikz Of .tex file , Easy to compile errors ( It is likely to change the original code format , Want to restore the original compilation , You will also report mistakes. ).

  • \documentclass{standalone} and \documentclass{book} Conflict

  • pdfTexify from compile 1 The next change is 3 Time , Now I Leave only tex Master file See if you can change bug, It turns out that bug It's not solved , In the end Compilation failed (700 individual error), There is a coding format conversion that I haven't seen before :gbk2uni. The solution is to download the template again , Paste and copy the source code ( The main reason is xxx.cls The file cannot be deleted , Lord tex You will not find the style latex Of cls Document instructions ).
     Insert picture description here

  • All in all , Using templates is the most convenient thing !!! Using templates is the most convenient thing !!! Using templates is the most convenient thing !!!

原网站

版权声明
本文为[Wang Xiaoxi WW]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131541088002.html