Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
tufte Rmarkdown中的gt表对齐_R_Tufte_Gt - Fatal编程技术网

tufte Rmarkdown中的gt表对齐

tufte Rmarkdown中的gt表对齐,r,tufte,gt,R,Tufte,Gt,我将gt表包括在Rmarkdown Tufte样式的HTML中。我希望将gt表对齐在主列的中心,而不是跨主列和边距的HTML的中心。我尝试过使用fig.align knitr选项以及tab.align命令。以下是一份带有rmd的回购协议,显示了问题: Tufte HTML中使用的gt表的示例代码: tibble(subject = "Joe", ytreat = "13", ycontrol = "9",

我将gt表包括在Rmarkdown Tufte样式的HTML中。我希望将gt表对齐在主列的中心,而不是跨主列和边距的HTML的中心。我尝试过使用fig.align knitr选项以及tab.align命令。以下是一份带有rmd的回购协议,显示了问题:

Tufte HTML中使用的gt表的示例代码:

tibble(subject = "Joe", ytreat = "13", ycontrol = "9", ydiff = "+4") %>% gt() tibble(主题=“乔”, ytreat=“13”, ycontrol=“9”, ydiff=“+4”)%%>% gt()
制作自己的css文件是修复它的一种方法。以下是代码行:

.gt_table {
  margin-left: 0 !important;
  margin-right: 0 !important;
  width: 55% !important;
}

谢谢余耀东的帮助

制作自己的css文件是修复它的一种方法。以下是代码行:

.gt_table {
  margin-left: 0 !important;
  margin-right: 0 !important;
  width: 55% !important;
}

谢谢余耀东的帮助

另一种方法是定义钩子函数:

knitr::knit_hooks$set(gtbl = function(before, options){
if (before) {
paste( '<style> .gt_table {width: 100% !important;} </style>',
       '<div class="figure"><p class="caption marginnote shownote">', 
       options$fig.cap, 
       '</p>', 
       sep="")
} else { "</div>" }
})
其中fig.cap提供了右对齐的标题


钩子函数记录在

中。另一种方法是定义钩子函数:

knitr::knit_hooks$set(gtbl = function(before, options){
if (before) {
paste( '<style> .gt_table {width: 100% !important;} </style>',
       '<div class="figure"><p class="caption marginnote shownote">', 
       options$fig.cap, 
       '</p>', 
       sep="")
} else { "</div>" }
})
其中fig.cap提供了右对齐的标题


钩子函数记录在

中,制作自己的css文件是修复它的一种方法。以下是代码行:.gt_表{左边距:0!重要;右边距:0!重要;宽度:55%!重要;}感谢俞耀东的帮助!!制作自己的css文件是修复它的一种方法。以下是代码行:.gt_表{左边距:0!重要;右边距:0!重要;宽度:55%!重要;}感谢俞耀东的帮助!!