英文:
How can I have a line Break in the column headings in R huxreg when exporting to latex?
问题
这是一个简单的示例。
library(huxtable)
model1 <- lm(mpg ~ cyl + disp, data = mtcars)
huxreg1 <- huxreg("这是一个过长的标题\n只占一行" = model1)
print_latex(huxreg1)
查看HTML输出时,换行符有效。但在导出到LaTeX时则无效。
对于这种行为有简单的解决方案吗?
非常感谢您提前的帮助。
编辑:
英文:
Here is a minimal example.
library(huxtable)
model1 <- lm(mpg ~ cyl + disp, data = mtcars)
huxreg1<-huxreg("This is a tool long title \n for one row"= model1)
print_latex(huxreg1)
When looking at the html output, the line break works.
However not when exported to Latex.
Any simple Solutions for this behaviour?
Thank you very much in advance.
Edit:
答案1
得分: 1
此输出行包含列名
\multicolumn{1}{c!{\huxvb{0, 0, 0}{0}}}{\huxtpad{6pt}\centering \hspace{6pt} 这是一个工具的长标题 \newline 为一行 \hspace{6pt}\huxbpad{6pt}} \tabularnewline[-0.5pt]
您可以将\multicolumn{1}{c...
替换为\multicolumn{1}{p{4cm}...
,使标题所在的列宽为4cm(您可以将其替换为任何其他长度)。变量名称的字段可以以相同方式进行编辑。
或者,您可以使用此相关问题中提供的答案之一:链接。
英文:
This line in the output contains the column name
\multicolumn{1}{c!{\huxvb{0, 0, 0}{0}}}{\huxtpad{6pt}\centering \hspace{6pt} This is a tool long title \newline for one row \hspace{6pt}\huxbpad{6pt}} \tabularnewline[-0.5pt]
you can replace the \multicolumn{1}{c...
with \multicolumn{1}{p{4cm}...
which causes the column with the title to be 4cm wide (you can replace this by any other length. The fields with the variable names can be edited in the same fashion.
Alternatively you can use the one of the answers presented at this related question.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论