记录在LaTeX使用中的心得,仅为笔记,文章有待重排。

Mac VSCode+LaTeX Workshop 引用文献编译方式

参照:https://www.bilibili.com/video/BV1TD4y1D7YV/

settings.conf 中的 latex-workshop.latex.recipes 里添加:

 {
   "name": "xelatex -> bibtex -> xelatex*2",
   "tools": [
     "xelatex",
     "bibtex",
     "xelatex",
     "xelatex"
   ]
 },

使用xelatex编译,再使用bib生成引用文献,再使用xelatex两次,编译成功。

引用的方式:

啦啦啦\cite{hadoop-env}

\bibliographystyle{IEEEtran} %引用风格
\bibliography{thesis} %./thesis.bib

(beamer同样适用)

多文档管理

参照TJU-Thesis

GIT管理

git ignore文件

.DS_Store
.texpadtmp
.stfolder
.vscode
# main.pdf
tjumain.pdf
# tmp files of ppt,excel documents
~$*
~$figures.xlsx
~$figures.pptx

*.toc
*.synctex(busy)
*.aux
*.bbl
*.blg
*.log
*.synctex.gz
*.fls
*.fdb_latexmk
*.out
*.thm

$\LaTeX$ 公式

妈咪说LaTeXLive帮助文档:在线LaTeX公式编辑器-帮助文档 (latexlive.com)

不同字体:

\begin{array}{c}
\mathscr{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \\
\mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \\
\mathfrak{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \\
\mathbb{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \\
\mathrm{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \\
\mathbf{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \\
ABCDEFGHIJKLMNOPQRSTUVWXYZ \\
\boldsymbol{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \\
\mathsf{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
\end{array}

$$ \begin{array}{c} \mathscr{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \\ \mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \\ \mathfrak{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \\ \mathbb{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \\ \mathrm{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \\ \mathbf{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \\ ABCDEFGHIJKLMNOPQRSTUVWXYZ \\ \boldsymbol{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \\ \mathsf{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \end{array} $$

文件格式排布

页眉

小写c表示只有中央,大写C表示除了中央,还可能有两边。

\pagestyle{fancy}
\fancyhead[c]{  \includegraphics[scale=0.5]{figures/school}  \@cheading}            % 首页页眉格式
\fancyfoot[c]{\thepage}

lstlisting

[firstnumber=100] %第一个数字为100

[firstnumber=last] %起始行数为上一段lstlisting环境结尾的行数

[caption={MyCode1}] %说明

[caption={[Code2] An very important code}] %可分别添加一个短的和长的caption

[label=Code1] % 标签

[title=Code1] %可以去掉label产

\begin{lstlisting}[language=Python,caption=Import \lstinline{meta_demos},label={lst:df_list}]
#导入数据表
#表头
meta_header = sc.textFile("/ZHANGYIMING/csgodata/archive/esea_meta_demos.part1.csv").first()
#raw data 创建RDD
meta_1_RDD = sc.textFile("/ZHANGYIMING/csgodata/archive/esea_meta_demos.part1.csv").filter(lambda x:x !=meta_header).map(lambda x: x.split(","))
meta_2_RDD = sc.textFile("/ZHANGYIMING/csgodata/archive/esea_meta_demos.part2.csv").filter(lambda x:x !=meta_header).map(lambda x: x.split(","))
\end{lstlisting}

\begin{lstlisting}[language=Python,firstnumber=last]
meta_df.show(5)
\end{lstlisting}

行间代码(抄写)

普通\verb可能产生缩进。

\verb| |
\lstinline{}

图片

\begin{figure}[htpb]
    \centering
    \includegraphics[width=\linewidth]{figures/hierachical}
    \caption{Hierachical Structure}
    \label{fig:hirs}
\end{figure}

图片组

\begin{figure}[htbp]
    \centering  %图片全局居中
    \subfigbottomskip=2pt %两行子图之间的行间距
    \subfigcapskip=-5pt %设置子图与子标题之间的距离
    \subfigure[\lstinline{dmg} Schema]{
        \includegraphics[width=0.48\linewidth]{figures/dmg-schema}}
    \subfigure[\lstinline{kill} Schema]{
        \includegraphics[width=0.48\linewidth]{figures/kill-schema}}
      \\
    \subfigure[\lstinline{grenades} Schema]{
        \includegraphics[width=0.48\linewidth]{figures/gre-schema}}
    %\quad
    \subfigure[\lstinline{mm} Schema]{
        \includegraphics[width=0.48\linewidth]{figures/mm-schema}}
    \caption{Schemas of the rest of DataFrames}
    \label{fig:othsche}
\end{figure}

两行两列

\begin{figure}[htbp]
    \centering  %图片全局居中

    \subfloat[\lstinline{dmg} Schema]{
        \includegraphics[width=0.48\linewidth]{figures/dmg-schema}}
    \subfloat[\lstinline{kill} Schema]{
        \includegraphics[width=0.48\linewidth]{figures/kill-schema}}
      \\
    \subfloat[\lstinline{grenades} Schema]{
        \includegraphics[width=0.48\linewidth]{figures/gre-schema}}
    %\quad
    \subfloat[\lstinline{mm} Schema]{
        \includegraphics[width=0.48\linewidth]{figures/mm-schema}}
    \caption{Schemas of the rest of DataFrames}
    \label{fig:othsche}
\end{figure}

两行两列

subcaptionbox

\begin{figure}[htbp]
    \centering  %图片全局居中
    \subcaptionbox{hitbox records}{
        \includegraphics[height=16em]{figures/hitbox-ct}}
  \subcaptionbox{hitbox damages}{
        \includegraphics[height=16em]{figures/hitbox-sum}}

  \caption{Records and damages counting of different hitbox}\label{fig:hitbox-raw}
\end{figure}

image-20230609180107319

表格组

\begin{table}[htbp]
  \caption{Hitboxes Statistics}\label{tab:pwnono1}
  \vspace{1em}
  \centering
\begin{subtable}[c]{0.3\textwidth}
  \centering
  \begin{tabular}{llr}
    \toprule
      hitbox &    count \\
    \midrule
        Chest &  4225631 \\
    Stomach &  1811283 \\
        Head &  1478655 \\
      Generic &  1394708 \\
    RightArm &   715480 \\
  RightLeg &   333583 \\
    LeftLeg &   298783 \\
    LeftArm &   258125 \\
          8 &    21934 \\
    \bottomrule
  \end{tabular}
  \caption{records}
\end{subtable}\hspace*{0.4cm}
\begin{subtable}[c]{0.7\textwidth}
  \centering
  \begin{tabular}{llrrr}
      \toprule
      hitbox &      tot\_dmg &       hp\_dmg &     arm\_dmg \\
      \midrule
      Chest &  115286584.0 &  102746528.0 &  12540056.0 \\
        Head &  110507583.0 &   96296187.0 &  14211396.0 \\
    Stomach &   57601555.0 &   50948744.0 &   6652811.0 \\
    RightArm &   19570309.0 &   17501191.0 &   2069118.0 \\
      Generic &   17688686.0 &   14860317.0 &   2828369.0 \\
    RightLeg &    7112794.0 &    7112794.0 &         0.0 \\
    LeftArm &    6935885.0 &    6165103.0 &    770782.0 \\
    LeftLeg &    6319436.0 &    6319436.0 &         0.0 \\
          8 &     566094.0 &     496159.0 &     69935.0 \\
      \bottomrule
  \end{tabular}
  \caption{damages}
\end{subtable}
\hfill

\vspace{\baselineskip}
\end{table}

image-20230609175613450

跨栏表格

\begin{multicols}{2}

  %\caption{Example }\label{tab:hahahahaha}
  \vspace{0.5em}\centering
 % \resizebox{\textwidth}{12em}{

  \let\mcnewpage=\newpage
  \makeatletter
  \renewcommand \newpage{    %欺骗分栏为分页
    \if@firstcolumn
    \hrule width\linewidth height0pt
    \columnbreak
    \else
    \mcnewpage
    \fi
  }

\begin{supertabular}{llr}
  \toprule
  {} &            wp &  count\_h  \\
  \midrule
  2  &           USP &   130791  \\
  15 &         P2000 &    15398  \\
  2  &           USP &   130791  \\
  15 &         P2000 &    15398  \\
  3  &         Glock &   116769  \\
  \bottomrule
  \end{supertabular}%}
  \vspace{\baselineskip}


inner site or outer site.
Before we do that though, we have to define what is considered Inner/Outer
site. Using some basic rectangles, I can draw sites on the map and then define
them via simple top-left, bottom-right coordinates.
First determine the boundaries of bomb sites. Defining the callout and make
up a function returning callout flag.
\end{multicols}

图表并排

(11条消息) Latex图表并列_御风而行Carrie的博客-CSDN博客_latex 图表并列

并排显示使,minipage 间不要空行!

\begin{figure}[h!]
  \centering
\begin{minipage}[t]{.49\linewidth}
  \centering
    \tabcaption{Winning rounds}\label{tab:winrd-site}
    \begin{tabular}{lrr}
      \toprule
      {} & \multicolumn{2}{l}{count} \\
      bomb\_site &     A &     B \\
      map         &       &       \\
      \midrule
      de\_cache    &  1819 &  1375 \\
      de\_cbble    &   346 &   434 \\
      de\_dust2    &  2123 &  1537 \\
      de\_inferno  &  1065 &   938 \\
      de\_mirage   &  2544 &  1955 \\
      de\_overpass &   428 &   557 \\
      de\_train    &   257 &   204 \\
      \bottomrule
  \end{tabular}
\end{minipage}
\begin{minipage}[t]{.49\linewidth}
    \centering
    \figcaption{Bomb Planting Counts}\label{fig:bscount2}
    \includegraphics[height=18em]{figures/xiuzheng}
\end{minipage}

\end{figure}

image-20230609175348013

textwidth:版面宽度

linewidth:栏宽

正则表达式

\\subfloat\[([\s\S]*?)\]\{

空行

\vspace{2em}

空格

\quad

颜色

v2-19ad003c8df51ba7d7fdd7cc6ad78f38_r

settings

 "latex-utilities.liveReformat.enabled": true,
    "latex-utilities.formattedPaste.image.template": [

        "\\begin{figure}[!htb]",
        "\t\\centering",
        "\t\\includegraphics[$1]{${imageFilePath}}",
        "\t\\caption{${imageFileNameWithoutExt/[-]/ /}}",
        "\t\\label{fig:${imageFileNameWithoutExt}}",
        "\\end{figure}",
        ""
    ],
    "latex-utilities.formattedPaste.useAsDefault": true,