我试图将表格放在 R Markdown 附录的第一页中,如下所示:
\newpage
# References {-}
<div id="refs"></div>
\newpage
# Appendix {-}
\setcounter{table}{0}
\renewcommand{\thetable}{A\arabic{table}}
```{r pre_table_appendix, message=FALSE, warning=FALSE, echo=FALSE, include=FALSE, fig.pos="H"}
tab <- matrix(c("text1", "text2", "text3", "text4",
"text1", "text2", "text3", "text4",
"text1", "text2", "text3", "text4",
"text1", "text2", "text3", "text4"), ncol=4, byrow=TRUE)
colnames(tab) <- c('Variable','Variable','Variable','Variable')
rownames(tab) <- NULL
tab <- as.table(tab)
table_appendix <- kbl(tab, longtable = T, booktabs = T, row.names = 0, caption = "Title.") %>%
kable_styling(latex_options = c("repeat_header"))
```
\begin{landscape}
```{r table_appendix_f, echo=FALSE}
table_appendix
```
\end{landscape}
但是,因为我的 table_appendix 是横向的,所以我最终得到一个空白页,其中只有“附录”,然后另一页包含实际的表格。有人知道如何将表格与附录放在一起吗?
最佳答案
如果我能正确理解你的话...
添加到我们的标题:
- \usepackage{pdflscape}
- \newcommand{\blandscape}{\begin{landscape}}
- \newcommand{\elandscape}{\end{landscape}}
LaTeX 引擎应该是 pdflatex
。
问题中的代码:
\newpage
# References {-}
<div id="refs"></div>
\newpage
\blandscape
# Appendix {-}
\setcounter{table}{0}
\renewcommand{\thetable}{A\arabic{table}}
```{r pre_table_appendix, message=FALSE, warning=FALSE, echo=FALSE, include=FALSE, fig.pos="H"}
library(kableExtra)
tab <- matrix(c("text1", "text2", "text3", "text4",
"text1", "text2", "text3", "text4",
"text1", "text2", "text3", "text4",
"text1", "text2", "text3", "text4"), ncol=4, byrow=TRUE)
colnames(tab) <- c('Variable','Variable','Variable','Variable')
rownames(tab) <- NULL
tab <- as.table(tab)
table_appendix <- kbl(tab, longtable = T, booktabs = T, row.names = 0, caption = "Title.") %>%
kable_styling(latex_options = c("repeat_header"))
```
```{r table_appendix_f, echo=FALSE}
table_appendix
```
\elandscape
\newpage
ccontent
content
content
content
content
附注关于页码的问题,我想你是知道的。
没有这个问题:
添加到标题:-\usepackage[paper=A4]{typearea}
\newpage
\KOMAoptions{paper=landscape,DIV=current}
\recalctypearea
# Appendix {-}
*** your code***
```{r table_appendix_f, echo=FALSE}
table_appendix
```
\newpage
\KOMAoptions{paper=portrait,DIV=current}
\recalctypearea
ccontent
content
瞧:)
!!! 但请记住,它会影响您的利润。在打印文档之前更好地检查。
关于r - 附录当前给我一个只有标题的空白页 - R Markdown,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69997639/