> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/zh-cn/shen-ru-wen-zhang/02-a-quick-visual-guide-to-creating-table-cells-with-diagonal-lines-in-latex.md).

# 在 LaTeX 中创建带对角线的表格单元格的快速可视化指南

LaTeX 中有许多有助于创建表格的宏包—— [booktabs](https://www.ctan.org/pkg/booktabs) 就是一个很受欢迎的例子——而且现在网上也有越来越多的自动表格生成器可用（例如 [这个](https://www.tablesgenerator.com/)）它们是无需手动输入就能为表格生成 LaTeX 代码的绝佳方式。甚至还有一个宏包可以帮助你创建 [非常长的表格](https://www.overleaf.com/read/xxwzfxkxxjmc) ，它们可以跨越多页！但如果你想为表格中的某些单元格添加额外的样式或格式，该怎么办呢？

简单的答案是，通常会有相应的宏包！这里我们关注一种特定的单元格格式——如何创建带对角线的表格单元格。这些对角线通常用于表格的左上角，以便在同一个单元格中同时放置行标题和列标题，而可以用来实现这一点的有两个相似的宏包： `slashbox` 和 `diagbox`.

为了帮助你尝试这一点，我们添加了 [一个简短的示例](https://www.overleaf.com/read/zrnpkbmzvtk) ，演示如何使用这些宏包在表格单元格中生成对角线。有些人更喜欢使用 `diagbox` ，因为 `slashbox` 生成的线条可能会更锯齿状，而 `diagbox` 线条则更平滑；不过，我们在示例中同时包含了两种选项，这样你就可以自己决定！

此外，我们还录制了一个动画 GIF，展示如何将文件 `slashbox.sty` 从 CTAN 代码库直接添加到你的项目中。

![在 Overleaf 上使用 slashbox 和 diagbox LaTeX 宏包制作表格](/files/d023db69f1e6cd2d7e58a86249310a5c530f0ea1)

希望这对你有帮助，如果你想看到更多动画 GIF 教程，请 [告诉我们](https://www.overleaf.com/contact).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/zh-cn/shen-ru-wen-zhang/02-a-quick-visual-guide-to-creating-table-cells-with-diagonal-lines-in-latex.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
