Xtable header alignment left-aligned with the table or centered (using knitr)

I would like to align the header with a bold shape to the left, adjusted with the table, or if that doesn't work, at least centered, because I think it looks silly, the small table is centered and the corresponding caption stays aligned. Also, the left alignment of both the table and the header is not optimal.

It should be possible using latex.environments = "left"

, but I am getting an error like in this post.

I don't think the problem is with the link because I am getting the same error message with and without label="myLabel"

.

Here's the MWE:

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

      

Error (short form, for long version see this one again):

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

      

Does anyone know a solution? Left aligned to the left side of the table or center, I would be happy with any solution.

+3


source to share


1 answer


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



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

      

0


source







All Articles