如何使列与最宽条目一样宽?
对于我正在编写的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一般来说,在源文件中混合内容和布局规则并不是一个好主意。
这是有充分理由的:表的布局定义取决于输出格式。例如,如果您使用 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.
在这种情况下,使用 水平列表 可能更有意义,而不是一张桌子。渲染的结果接近您正在寻找的结果。语法如下所示:
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: