xtable标题对齐方式与表格对齐或居中对齐(使用knitr) [英] xtable caption alignment left aligned with table or centered (using knitr)

查看:116
本文介绍了xtable标题对齐方式与表格对齐或居中对齐(使用knitr)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一个左调整过的xtable图形标题与表格对齐,或者如果这样不起作用,至少要居中对齐,因为我认为将一个小表格居中并保留相应的标题看起来有点愚蠢对齐.此外,表格和标题的左对齐也不是最佳选择.

I'd like to align an xtable figure caption left adjusted with the table, or if that doesn't work, at least centered, because I think it looks kind of stupid a small table being centered and the corresponding caption being left aligned. Also, left aligning both table and caption is not optimal.

应该可以使用使用 latex.environments = "left",但是我收到一条错误消息,就像在帖子.

It should be possible using latex.environments = "left", but I get an error message, just like in this post.

我认为问题不在于引用,因为无论是否使用label="myLabel",我都会得到相同的错误消息.

I don't think the problem lies in the referencing, because I get the same error message with and without label="myLabel".

这里是MWE:

<<table, echo=FALSE, results='asis'>>=
print(xtable(lm(mpg~hp, data=mtcars), caption="Linear Model", label="myLabel") , caption.placement = "top", latex.environments="left")
@

错误(简写形式,长版请参见再次发布):

The error (short form, for long version see this post again):

Missing $ inserted.
Missing delimiter (. inserted)
Missing $ inserted
Missing \right. inserted

有人知道解决方案吗?左对齐表格的左侧或居中对齐,我对任何解决方案都很满意.

Does somebody know a solution? Left aligned with left side of the table or centered, I'd be happy with any solution.

推荐答案

好,所以我找到了一个解决方案,至少使用包

Ok so I found a solution to at least center the table captions, using package caption, specifying

\usepackage[
    singlelinecheck=false,
    justification=centering
]{caption}

这篇关于xtable标题对齐方式与表格对齐或居中对齐(使用knitr)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆