簡體   English   中英

標記為PDF的標題和圖標題問題

[英]Problem with header and fig captions in markdown to PDF

我試圖讓我的數字標題工作,但我有一些問題。 我的標題將無法正常工作或我的標題將顯示在圖下方。

我已經嘗試了\\ newpage,\\ pagebreak,\\在所有可能的位置,fig.pos,fig.height和fig.width但似乎沒有任何工作。 無法同時顯示標題和標題。

這是我的代碼:

output: pdf_document
fig_caption: yes
graphics: yes
keep_tex: yes
---

### Header(Will get under the plot in the pdf)

```{r plot, fig.cap="Hello World!"}
ggplot(data, aes(x=x, y=y)) + geom+point()
```
Text text text text text text text

sessionInfo()

R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS  10.14

Matrix products: default


attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggfortify_0.4.6 ggplot2_2.2.1   dplyr_0.7.4     knitr_1.17      pxweb_0.9.1    

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.13        bindr_0.1           compiler_3.4.2      highr_0.6           plyr_1.8.4          tools_3.4.2        
 [7] digest_0.6.18       gtable_0.2.0        jsonlite_1.5        evaluate_0.10.1     tibble_1.3.4        checkmate_1.8.5    
[13] viridisLite_0.2.0   pkgconfig_2.0.1     rlang_0.1.4         rstudioapi_0.7      curl_3.1            yaml_2.1.14        
[19] bindrcpp_0.2        gridExtra_2.3       httr_1.3.1          stringr_1.2.0       xml2_1.2.0          hms_0.4.2          
[25] grid_3.4.2          rprojroot_1.3-2     webshot_0.5.1       glue_1.2.0          data.table_1.10.4-3 R6_2.2.2           
[31] rmarkdown_1.8       RJSONIO_1.3-0       purrr_0.2.4         tidyr_0.7.2         readr_1.1.1         magrittr_1.5       
[37] backports_1.1.1     scales_0.5.0        htmltools_0.3.6     assertthat_0.2.0    rvest_0.3.2         colorspace_1.3-2   
[43] stringi_1.1.6       lazyeval_0.2.1      munsell_0.4.3

我無法重現你的問題,@奧斯卡。 我必須稍微調整你的代碼才能使它工作:

---
output: pdf_document
fig_caption: yes
graphics: yes
keep_tex: yes
---

### Header(Will get under the plot in the pdf)

```{r plot, fig.cap="Hello World!"}

library(ggplot2)
ggplot(mtcars, aes(x=mpg, y=cyl)) + geom_point()

```

我的sessionInfo:

R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] scales_1.0.0    ggpubr_0.2      magrittr_1.5    lubridate_1.7.4 forcats_0.4.0   purrr_0.3.0    
 [7] readr_1.3.1     tibble_2.0.1    tidyverse_1.2.1 broom_0.5.1     xlsx_0.6.1      gridExtra_2.3  
[13] stringr_1.4.0   ggplot2_3.1.0   tidyr_0.8.2     dplyr_0.8.0.1   plyr_1.8.4      knitr_1.21     

loaded via a namespace (and not attached):
 [1] tidyselect_0.2.5   xfun_0.4           rJava_0.9-10       haven_2.1.0        lattice_0.20-38   
 [6] colorspace_1.4-0   generics_0.0.2     htmltools_0.3.6    yaml_2.2.0         rlang_0.3.1       
[11] pillar_1.3.1       glue_1.3.0         withr_2.1.2        RColorBrewer_1.1-2 modelr_0.1.4      
[16] readxl_1.3.0       cellranger_1.1.0   munsell_0.5.0      gtable_0.2.0       rvest_0.3.2       
[21] evaluate_0.13      labeling_0.3       xlsxjars_0.6.1     highr_0.7          Rcpp_1.0.0        
[26] backports_1.1.3    jsonlite_1.6       hms_0.4.2          digest_0.6.18      stringi_1.3.1     
[31] grid_3.5.1         cli_1.0.1          tools_3.5.1        lazyeval_0.2.1     crayon_1.3.4      
[36] pkgconfig_2.0.2    xml2_1.2.0         assertthat_0.2.0   rmarkdown_1.11     httr_1.4.0        
[41] rstudioapi_0.9.0   R6_2.4.0           nlme_3.1-137       compiler_3.5.1    

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM