一些待解决的问题及好文收藏

如何解决latex中将公式放到表格中后公式字体变小的问题

在 LaTeX 中,将公式放入表格中可能导致公式字体变小的问题。这是因为表格默认使用了较小的字号。要解决这个问题,可以通过在表格中使用 \displaystyle 命令或者使用 array 宏包的 >{\displaystyle}c 来强制将公式显示为正常字号。下面是两种解决方案的示例代码:

方法一:使用 \displaystyle 命令

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{table}
\caption{示例表格}
\centering
\begin{tabular}{|c|c|}
\hline
\textbf{公式} & \textbf{说明} \\
\hline
$\displaystyle \frac{1}{2} \left( \frac{a}{b} \right)$ & 这是一个示例公式 \\
\hline
\end{tabular}
\end{table}
\end{document}

方法二:使用 array 宏包的 >{\displaystyle}c

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}

\begin{document}
\begin{table}
\caption{示例表格}
\centering
\begin{tabular}{|>{\displaystyle}c|c|}
\hline
\textbf{公式} & \textbf{说明} \\
\hline
\frac{1}{2} \left( \frac{a}{b} \right) & 这是一个示例公式 \\
\hline
\end{tabular}
\end{table}
\end{document}

LATEX表格如何设置偶数行为灰色背景

在 LaTeX 中,可以使用 xcolor 宏包来设置表格的偶数行为灰色背景。下面是一个示例代码,展示了如何实现这个效果:

\documentclass{article}
\usepackage[table]{xcolor}

\begin{document}
\begin{table}
  \rowcolors{2}{gray!25}{white} % 将偶数行设置为灰色背景,奇数行为白色背景
  \centering
  \begin{tabular}{|c|c|c|}
    \hline
    \rowcolor{gray!50} % 设置表头为灰色背景
    \textbf{1} & \textbf{2} & \textbf{3} \\
    \hline
    数据1 & 数据2 & 数据3 \\
    数据4 & 数据5 & 数据6 \\
    数据7 & 数据8 & 数据9 \\
    \hline
  \end{tabular}
  \caption{示例表格}
\end{table}
\end{document}

Latex参考文献分章编译

该方法仅适用于支持 biblatex 包的模板。

 \documentclass{book}
    \usepackage[backend=biber, style=numeric, refsection=chapter]{biblatex}
    \addbibresource{references.bib} % 这里替换为您的.bib文件

    \begin{document}

    \tableofcontents

    \chapter{引言}
    \begin{refsection}
    % 章节内容...
    \printbibliography[heading=subbibliography]
    \end{refsection}

    % 其他章节...

    % 在目录中添加无编号的参考文献小节
    \printbibliography[heading=bibintoc, title={参考文献}]
    \addcontentsline{toc}{chapter}{参考文献}

    \end{document}

VS CODE 自动补全

公式补齐

功能:输入$,自动出现$$并且光标位于中间。
方法:
首先使用Everything搜索\syntax\latex-language-configuration.json,我的文件路径是

C:\Users\Administrator\.vscode\extensions\james-yu.latex-workshop-10.1.0\syntax\latex-language-configuration.json

文件路径仅供大家参考,每个人的版本号不太一样。
然后在latex-language-configuration.json文件中搜索autoClosingPairs,在其中添加["$", "$"]即可。

Figure环境补齐

这个功能其实就是用户自定义代码块。latex自带的figure环境只能显示

\begin{figure}
\end{figure}

通过用户自定义代码块,输入figure,选择插入figure环境后,可以自动出现完整的figure代码,包括图片大小,图标题和图标签。


\begin{figure}[htbp]
\centering
\includegraphics[width=\textwidth]{XXX.png}
\caption{Caption.}
\label{Fig:label}
\end{figure}

方法:

  1. 打开User snippets命令面板(Files --> Preferences --> User snippets或ctrl + shift +P直接打开命令面板,输入 Configure User Snippets)
  2. 输入latex,定位至latex.json
  3. latex.jon文件中有默认的语法格式,我们只需要在大括号中加入以下内容即可
	"Insert Figure Environment": {
        "prefix": "figure",
        "body": [
            "\\begin{figure}[htbp]",
            "\\centering",
            "\\includegraphics[width=\\textwidth]{${1:XXX.png}}",
            "\\caption{${2:Caption.}}",
            "\\label{${3:Fig:label}}",
            "\\end{figure}"
        ],
        "description": "Insert a complete figure environment"
    }

latexdiff

参考教程:

代码高亮

  • 7
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

今天你比昨天博学了吗

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值