• LaTeX 公式与绘图技巧


    • LaTeX 公式与绘图技巧
    • 公式基本可以分为
      • 单一公式单一编号
      • 单一公式按行编号
      • 单一公式多个子编号
      • 单一公式部分子编号
      • 分段公式
    • 现在给出各自的代码
    • 单一公式单一编号
    1. 公式1:equation+aligned
    2. \begin{equation}
    3. \begin{aligned}
    4. a=&b+c\\
    5. b=&a+2\\
    6. c=&b-3
    7. \end{aligned}
    8. \end{equation}

    • 单一公式按行编号
    1. 公式2:align
    2. \begin{align}
    3. a=&b+c\\
    4. b=&a+2\\
    5. c=&b-3
    6. \end{align}

    • 单一公式多个子编号
    1. 公式3:subequations+align(对公式进行子编号)
    2. \begin{subequations}
    3. \begin{align}
    4. a=&b+c\\
    5. b=&a+2\\
    6. c=&b-3
    7. \end{align}
    8. \end{subequations}

    • 单一公式部分子编号
    1. 公式4:subequations+align+nonumber(部分子式不需要编号)
    2. \begin{subequations}
    3. \begin{align}
    4. a=&b+c\\
    5. b=&a+2\nonumber\\
    6. c=&b-3
    7. \end{align}
    8. \end{subequations}

    • 分段公式
    1. 公式5:subequations+align+cases(分段函数)
    2. \begin{subequations}
    3. \begin{align}
    4. y=&\begin{cases}
    5. a&x>0\\
    6. b&x<0
    7. \end{cases}\\
    8. f=&\begin{cases}
    9. c&x>0\\
    10. d&x<0
    11. \end{cases}
    12. \end{align}
    13. \end{subequations}

    • 为什么不使用split 
      • 因为split是针对单个公式的,虽然微操的好与align一样,但是不规范,不方便后来者微操,本质上和程序员写注释一样
    • 完整代码
    1. \documentclass{article}
    2. \usepackage{fancyhdr} % 自定义页面的页眉和页脚样式
    3. \usepackage{tocloft} % 控制目录(包括目录、表格目录和插图目录)样式的命令
    4. \usepackage{titlesec} % 自定义标题的样式,如章节标题、节标题等。
    5. \usepackage{lipsum} % 生成虚拟文本
    6. \usepackage{biblatex} % 管理和生成参考文献列表
    7. \usepackage{appendix} % 生成附录部分
    8. \usepackage{listings} % 排版源代码块
    9. \usepackage{geometry} % 设置页面布局
    10. \usepackage{graphicx} % 插入图像并排列
    11. \usepackage{subcaption} % 次级图像
    12. \usepackage{amsmath} %矩阵方能换行
    13. \usepackage{times} % 使用times new roman 字体
    14. \usepackage{xeCJK}
    15. \setCJKmonofont{仿宋}
    16. \numberwithin{equation}{section}%公式按章节编号
    17. \numberwithin{figure}{section}%图表按章节编号
    18. % 设置目录格式
    19. \renewcommand{\cfttoctitlefont}{\fontsize{15}{6}\normalfont} % 将目录标题字体
    20. \renewcommand{\cftsecfont}{\fontsize{15}{6}\normalfont} % 设置章节标题字体
    21. \renewcommand{\cftsubsecfont}{\fontsize{15}{6}\normalfont} % 设置子节标题字体
    22. \setlength{\cftbeforesecskip}{2em} % 设置章节之间的垂直距离
    23. \setlength{\cftbeforesubsecskip}{1em} % 设置子节之间的垂直距离
    24. % 设置页面布局
    25. \geometry{
    26. left=3cm,
    27. right=3cm,
    28. top=3cm,
    29. bottom=2cm,
    30. }
    31. % 设置代码布局
    32. \lstset{
    33. language=Python,
    34. numbers=left,
    35. frame=single,
    36. breaklines=true,
    37. breakatwhitespace=false,
    38. basicstyle=\small\ttfamily,
    39. showspaces=false, % 显示空格
    40. }
    41. % 设置页眉页脚
    42. \pagestyle{fancy}
    43. \fancyhf{}
    44. \fancyhead[L]{小文章模版}
    45. \fancyhead[C]{钱睿雯制}
    46. \fancyhead[R]{\thepage}
    47. \renewcommand{\headrulewidth}{0.4pt}
    48. \titleformat{\section}{\fontsize{15}{6}\bfseries\itshape}{\thesection}{1em}{}
    49. \titleformat{\subsection}{\fontsize{15}{6}\bfseries}{\thesubsection}{1em}{}
    50. \begin{document}
    51. \thispagestyle{fancy}
    52. \pagenumbering{gobble}
    53. \begin{center}
    54. \textbf{{\fontsize{15}{14}\itshape\selectfont
    55. LaTeX 小文章模版
    56. }}
    57. \vspace{2em}
    58. \textbf{{\fontsize{15}{14}\itshape\selectfont
    59. \today{}
    60. }}
    61. \vspace{2em}
    62. \end{center}
    63. \pagenumbering{arabic} % 正文页开始
    64. \section{公式编辑技巧}
    65. \quad
    66. 公式1:equation+aligned
    67. \begin{equation}
    68. \begin{aligned}
    69. a=&b+c\\
    70. b=&a+2\\
    71. c=&b-3
    72. \end{aligned}
    73. \end{equation}
    74. 公式2:align
    75. \begin{align}
    76. a=&b+c\\
    77. b=&a+2\\
    78. c=&b-3
    79. \end{align}
    80. 公式3:subequations+align(对公式进行子编号)
    81. \begin{subequations}
    82. \begin{align}
    83. a=&b+c\\
    84. b=&a+2\\
    85. c=&b-3
    86. \end{align}
    87. \end{subequations}
    88. 公式4:subequations+align+nonumber(部分子式不需要编号)
    89. \begin{subequations}
    90. \begin{align}
    91. a=&b+c\\
    92. b=&a+2\nonumber\\
    93. c=&b-3
    94. \end{align}
    95. \end{subequations}
    96. 公式5:subequations+align+cases(分段函数)
    97. \begin{subequations}
    98. \begin{align}
    99. y=&\begin{cases}
    100. a&x>0\\
    101. b&x<0
    102. \end{cases}\\
    103. f=&\begin{cases}
    104. c&x>0\\
    105. d&x<0
    106. \end{cases}
    107. \end{align}
    108. \end{subequations}
    109. \begin{thebibliography}{9}
    110. \bibitem{ref1} Author A. Title of the paper. Journal name, year.
    111. \bibitem{ref2} Author B. Title of the book. Publisher, year.
    112. \end{thebibliography}
    113. % 附录页
    114. \newpage
    115. \appendix % 标记后续部分为附录
    116. \section*{Appendix}
    117. This is the content of the appendix.
    118. \begin{lstlisting}
    119. # Python example
    120. def hello_world():
    121. print("Hello, World!")
    122. print("Hello, World!","Hello, World!","Hello, World!","Hello, World!","Hello, World!","Hello, World!","Hello, World!","Hello, World!","Hello, World!","Hello, World!","Hello, World!","Hello, World!")
    123. hello_world() # call hello_world
    124. \end{lstlisting}
    125. \end{document}

    • 实现效果

    LaTeX 表格绘制技巧

    • 表格基本可以分为
      • 三线表
      • 常用表
      • 调整线框
      • 调整对齐方式
        • c,l,r

    • 只有tabular 无法生成caption
      • 这里不设置对齐方式
    1. 表格1:三线表(不使用table环境):
    2. \begin{center}
    3. \begin{tabular}{ccc}
    4. \toprule
    5. Header 1 & Header 2 & Header 3 \\
    6. \midrule
    7. Data 1 & Data 2 & Data 3 \\
    8. Data 4 & Data 5 & Data 6 \\
    9. \bottomrule
    10. \end{tabular}
    11. \end{center}
    12. 表格2:三线表(使用table环境)
    13. \begin{table}
    14. \caption{三线表}
    15. \begin{center}
    16. \begin{tabular}{ccc}
    17. \toprule
    18. Header 1 & Header 2 & Header 3 \\
    19. \midrule
    20. Data 1 & Data 2 & Data 3 \\
    21. Data 4 & Data 5 & Data 6 \\
    22. \bottomrule
    23. \end{tabular}
    24. \end{center}
    25. \end{table}


    • 调整表格过于复杂,我也只会两个操作,我认为已经足够的了
      • 不追求确定每一列的宽度,只要求对齐方式
        • 注意,这样无法实现自动换行,所以需要谨慎
      • 追求每一列的宽度,但是对齐方式通通为左对齐
    • 表格三:
    1. \begin{tabular}{clr}
    2. \hline
    3. $a_b$ & $a_b+c_d+e_f+g_h$ & $m_n$ \\
    4. \hline
    5. $a_b+c_d+e_f+g_h+m_n-k_j$ & Data 2 & Data 3 \\
    6. Data 4 & Data 5 & $1+2+3+a_b+c_d+e_f+g_h+m_n-k_j+5+6+7$ \\
    7. \hline
    8. \end{tabular}


    • 表格四:  

     

    1. \begin{tabular}{p{2cm}p{4cm}p{6cm}}
    2. \hline
    3. $a_b$ & $a_b+c_d+e_f+g_h$ & $m_n$ \\
    4. \hline
    5. $a_b+c_d+e_f+g_h+m_n-k_j$ & Data 2 & Data 3 \\
    6. Data 4 & Data 5 & $1+2+3+a_b+c_d+e_f+g_h+m_n-k_j+5+6+7$ \\
    7. \hline
    8. \end{tabular}

  • 相关阅读:
    linux下安装mysql客户端client
    31岁才转行程序员,目前34了,我来说说我的经历和一些感受吧...
    RDD的创建方式
    2022钉钉杯初赛A题(银行卡电信诈骗危险预测)
    kubernetes--资源调度
    A-level化学例题分析(二)
    趣味算法------开灯问题
    provide/inject 依赖注入
    Qt重定向QDebug,Qt/C++开源作品39-日志输出增强版V2022
    《学成在线》微服务实战项目实操笔记系列(P92~P120)【下】
  • 原文地址:https://blog.csdn.net/Chandler_river/article/details/133832009