LaTeX 中表格中的自定义对齐文本
基本上,我想在 LaTeX
中生成下表(注意第二个单元格的“逗号对齐”):
----------------------------------------
| Header1 | Header2 |
----------------------------------------
| 1 | "value 1" , "value 2" |
| 2 | "one" , "two" |
| 3 | "abcdefheasal" , "ok" |
----------------------------------------
我在 中生成上面表格的方式LaTeX
如下:
\begin{tabular}{|c|l|}
\hline
Header1 & Header2 \\
\hline
1 & ``value 1'' , ``value 2'' \\
2 & ``one'' , ``two'' \\
3 & ``abcdefheasal'' , ``ok'' \\
\hline
\end{tabular}
但显然,该代码生成以下内容(显然没有“逗号对齐”):
-----------------------------------
| Header1 | Header2 |
-----------------------------------
| 1 | "value 1" , "value 2" |
| 2 | "one" , "two" |
| 3 | "abcdefheasal" , "ok" |
-----------------------------------
将后一个表格转换为表格的最佳方法是什么我想?即前者
Basically, I want to produce the following table in LaTeX
(Notice the "comma alignment" of the second cell) :
----------------------------------------
| Header1 | Header2 |
----------------------------------------
| 1 | "value 1" , "value 2" |
| 2 | "one" , "two" |
| 3 | "abcdefheasal" , "ok" |
----------------------------------------
The way I would produce the table above in LaTeX
is as follows:
\begin{tabular}{|c|l|}
\hline
Header1 & Header2 \\
\hline
1 & ``value 1'' , ``value 2'' \\
2 & ``one'' , ``two'' \\
3 & ``abcdefheasal'' , ``ok'' \\
\hline
\end{tabular}
But obviously, that code produces the following (obviously without the "comma alignment") :
-----------------------------------
| Header1 | Header2 |
-----------------------------------
| 1 | "value 1" , "value 2" |
| 2 | "one" , "two" |
| 3 | "abcdefheasal" , "ok" |
-----------------------------------
What is the best way to turn the latter table into the one I want? i.e. the former
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
作为对 Martin B 答案的修改,请考虑使用
@
符号来制作列分隔符:另请注意,
multicolumn
中需要一个额外的管道来绘制垂直线第一行。As a modification to Martin B's answer, consider using the
@
sign to make a column separator:Also note that an extra pipe is needed in the
multicolumn
to draw the vertical line on the first row.我建议使用三列表,然后合并第二列和第三列的标题,如下所示:
I would suggest using a three-column table, then merging the header of the second and third column, as follows: