如何使列与最宽条目一样宽?

发布于 2024-09-02 12:01:59 字数 612 浏览 14 评论 0原文

对于我正在编写的 gcc 备忘单,我想创建一个表来描述 gcc 如何解释不同的文件结尾。到目前为止我创建的表定义如下:

|======================================================================
|.c    |C source code which must be preprocessed.
|.i    |C source code which should not be preprocessed.
|.h    |C header file to be turned into a precompiled header.
|.s    |Assembler code.
|other |
An object file to be fed straight into linking. Any file name with no
recognized suffix is treated this way.
|======================================================================

我遇到的问题是该表跨越了总页面宽度,但我想要的是每列的宽度仅与其最宽的条目一样宽,并且该表将仅跨越需要多大的力量。

For a gcc cheatsheet I'm writing, I want to create a table which should describe how gcc interprets different file endings. The table I created so far is defined as follows:

|======================================================================
|.c    |C source code which must be preprocessed.
|.i    |C source code which should not be preprocessed.
|.h    |C header file to be turned into a precompiled header.
|.s    |Assembler code.
|other |
An object file to be fed straight into linking. Any file name with no
recognized suffix is treated this way.
|======================================================================

The problem I have is that the table spans the total page width, but what I want is that each column only is as wide as it's widest entry, and that the table will span only as much witdh as it needs.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时间海 2024-09-09 12:01:59

一般来说,在源文件中混合内容和布局规则并不是一个好主意。

这是有充分理由的:表的布局定义取决于输出格式。例如,如果您使用 html 作为文档的后端,css 将是一种合适的技术来布局文档。另一方面,例如,如果您使用格式化对象处理器创建 pdf 文件,例如 apache fop,自动并非所有 FO 处理器都支持表布局。

回答您的问题:这取决于输出格式以及如何正确定义表格布局。在大多数情况下,AsciiDoc 标记中的定义是错误的方式。

In general, it's not a good idea to mix content and layout rules within the source file.

That is for a good reason: The layout definition of the table depends on the output format. If you use for example html as backend for the document, css would be an appropriate technology to layout the document. On the other hand, e.g. if you use a formatting objects processor to create pdf files like apache fop, automatic table-layout is not supported by all FO processors.

To answer your question: It depends on the output format, how the table layout will be defined correctly. A definition within the AsciiDoc markup is the wrong way in most cases.

森罗 2024-09-09 12:01:59

在这种情况下,使用 水平列表 可能更有意义,而不是一张桌子。渲染的结果接近您正在寻找的结果。语法如下所示:

[horizontal]
+.c+:: C source code which must be preprocessed.
+.i+:: C source code which should not be preprocessed.
+.h+:: C header file to be turned into a precompiled header.
+.s+:: Assembler code.
other:: An object file to be fed straight into linking. Any file name with no recognized suffix is treated this way.

It might make more sense to use a horizontal list in this case rather than a table. The rendered result is close to what you are looking for. The syntax would look like the following:

[horizontal]
+.c+:: C source code which must be preprocessed.
+.i+:: C source code which should not be preprocessed.
+.h+:: C header file to be turned into a precompiled header.
+.s+:: Assembler code.
other:: An object file to be fed straight into linking. Any file name with no recognized suffix is treated this way.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文