├── inst ├── zip │ ├── poem.txt │ ├── poster.txt │ ├── cchess.txt │ ├── article.txt │ ├── skak.txt │ ├── dnd_dev.txt │ ├── guitar.txt │ ├── igo.txt │ ├── mail.txt │ ├── thesis_classic.txt │ ├── calendar.txt │ ├── article_mdpi.txt │ ├── article_zh.txt │ ├── chemistry_zh.txt │ ├── discussion.txt │ ├── musix.txt │ ├── yihui_mini.txt │ ├── yihui_zh.txt │ ├── journal.txt │ ├── thesis_ubt.txt │ ├── yihui_crc.txt │ ├── yihui_demo.txt │ ├── nte_zh.txt │ ├── thesis_zju_zh.txt │ ├── chemistry.txt │ ├── thesis_mypku_zh.txt │ ├── thesis_pku_zh.txt │ ├── docsens.txt │ ├── igo.zip │ ├── rbasics.txt │ ├── mail.zip │ ├── musix.zip │ ├── poem.zip │ ├── skak.zip │ ├── article.zip │ ├── calendar.zip │ ├── cchess.zip │ ├── dnd_dev.zip │ ├── docsens.zip │ ├── guitar.zip │ ├── journal.zip │ ├── nonpar.txt │ ├── nonpar.zip │ ├── nte_zh.zip │ ├── poster.zip │ ├── rbasics.zip │ ├── yihui_zh.zip │ ├── article_zh.zip │ ├── chemistry.zip │ ├── discussion.zip │ ├── thesis_ubt.zip │ ├── yihui_crc.zip │ ├── yihui_demo.zip │ ├── yihui_mini.zip │ ├── article_mdpi.zip │ ├── chemistry_zh.zip │ ├── thesis_pku_zh.zip │ ├── thesis_zju_zh.zip │ ├── thesis_classic.zip │ └── thesis_mypku_zh.zip ├── yml │ ├── _bookdown.yml │ ├── _output_md.yml │ ├── _output_epub_book.yml │ ├── _output_html_document2.yml │ ├── _output_word_document2.yml │ ├── _output_gitbook.yml │ └── _output.yml ├── images │ ├── logo.png │ ├── mail.pdf │ ├── bookdownplus-logo.pdf │ ├── bookdownplus-logopic.pdf │ └── bookdownplus-logotxt.pdf ├── proj │ ├── bookdownplus │ ├── index.Rmd │ └── body.Rmd └── bib │ └── bib.bib ├── fonts └── fonts.zip ├── inst2 ├── showcase │ ├── musixskak.jpg │ ├── bookdownplus_mail.jpg │ ├── bookdownplus_poem.jpg │ ├── bookdownplus_skak.jpg │ ├── bookdownplus_guitar.jpg │ ├── bookdownplus_nonpar.jpg │ ├── bookdownplus_nte_zh.jpg │ ├── bookdownplus_poster.jpg │ ├── bookdownplus_article.jpg │ ├── bookdownplus_calendar.jpg │ ├── bookdownplus_chemistry.jpg │ ├── bookdownplus_dnd_dev.jpg │ ├── bookdownplus_docsens.jpg │ ├── bookdownplus_journal.jpg │ ├── bookdownplus_rbasics.jpg │ ├── bookdownplus_yihui_crc.jpg │ ├── bookdownplus_yihui_zh.jpg │ ├── bookdownplus_article_zh.jpg │ ├── bookdownplus_discussion.jpg │ ├── bookdownplus_thesis_pku.jpg │ ├── bookdownplus_thesis_ubt.jpg │ ├── bookdownplus_thesis_zju.jpg │ ├── bookdownplus_yihui_demo.jpg │ ├── bookdownplus_yihui_mini.jpg │ ├── bookdownplus_article_mdpi.jpg │ ├── bookdownplus_thesis_classic.jpg │ └── bookdownplus_thesis_mypku.jpg ├── style │ ├── gitbook.css │ ├── tweaklist.sty │ ├── newtxtext.sty │ └── expl3.sty └── tex │ └── template_default.tex ├── .Rbuildignore ├── NAMESPACE ├── man ├── bd.Rd ├── mail_font.Rd ├── template.Rd ├── mail_style.Rd ├── mail_theme.Rd ├── mail_bodysize.Rd ├── mail_fontsize.Rd ├── more_output.Rd ├── poster_theme.Rd ├── share.Rd └── bookdownplus.Rd ├── bookdownplus.Rproj ├── .gitattributes ├── DESCRIPTION ├── .gitignore ├── DESCRIPTION.bak ├── readme.md └── R └── fun.R /inst/zip/poem.txt: -------------------------------------------------------------------------------- 1 | poem book 2 | -------------------------------------------------------------------------------- /inst/zip/poster.txt: -------------------------------------------------------------------------------- 1 | poster 2 | -------------------------------------------------------------------------------- /inst/zip/cchess.txt: -------------------------------------------------------------------------------- 1 | Chinese chess 2 | -------------------------------------------------------------------------------- /inst/zip/article.txt: -------------------------------------------------------------------------------- 1 | academic article 2 | -------------------------------------------------------------------------------- /inst/zip/skak.txt: -------------------------------------------------------------------------------- 1 | drawing chess diagram 2 | -------------------------------------------------------------------------------- /inst/zip/dnd_dev.txt: -------------------------------------------------------------------------------- 1 | I don't know what it is 2 | -------------------------------------------------------------------------------- /inst/zip/guitar.txt: -------------------------------------------------------------------------------- 1 | book with guitar chords 2 | -------------------------------------------------------------------------------- /inst/zip/igo.txt: -------------------------------------------------------------------------------- 1 | drawing Go game diagrams 2 | -------------------------------------------------------------------------------- /inst/zip/mail.txt: -------------------------------------------------------------------------------- 1 | personal or business mail 2 | -------------------------------------------------------------------------------- /inst/zip/thesis_classic.txt: -------------------------------------------------------------------------------- 1 | classic thesis 2 | -------------------------------------------------------------------------------- /inst/yml/_bookdown.yml: -------------------------------------------------------------------------------- 1 | book_filename: original 2 | -------------------------------------------------------------------------------- /inst/zip/calendar.txt: -------------------------------------------------------------------------------- 1 | monthly or weekly calendar 2 | -------------------------------------------------------------------------------- /inst/yml/_output_md.yml: -------------------------------------------------------------------------------- 1 | bookdown::md_document: default 2 | -------------------------------------------------------------------------------- /inst/zip/article_mdpi.txt: -------------------------------------------------------------------------------- 1 | academic article by mdpi 2 | -------------------------------------------------------------------------------- /inst/zip/article_zh.txt: -------------------------------------------------------------------------------- 1 | academic article in Chinese 2 | -------------------------------------------------------------------------------- /inst/zip/chemistry_zh.txt: -------------------------------------------------------------------------------- 1 | chemistry book in Chinese 2 | -------------------------------------------------------------------------------- /inst/zip/discussion.txt: -------------------------------------------------------------------------------- 1 | article in discussion format 2 | -------------------------------------------------------------------------------- /inst/zip/musix.txt: -------------------------------------------------------------------------------- 1 | typesetting music and related stuff 2 | -------------------------------------------------------------------------------- /inst/zip/yihui_mini.txt: -------------------------------------------------------------------------------- 1 | a mini demo book by Yihui Xie 2 | -------------------------------------------------------------------------------- /inst/zip/yihui_zh.txt: -------------------------------------------------------------------------------- 1 | the demo in Chinese by Yihui Xie 2 | -------------------------------------------------------------------------------- /inst/yml/_output_epub_book.yml: -------------------------------------------------------------------------------- 1 | bookdown::epub_book: default 2 | -------------------------------------------------------------------------------- /inst/zip/journal.txt: -------------------------------------------------------------------------------- 1 | laboratory journal or personal diary 2 | -------------------------------------------------------------------------------- /inst/zip/thesis_ubt.txt: -------------------------------------------------------------------------------- 1 | thesis of University of Bayreuth 2 | -------------------------------------------------------------------------------- /inst/zip/yihui_crc.txt: -------------------------------------------------------------------------------- 1 | writing a book of Chapman & Hall 2 | -------------------------------------------------------------------------------- /inst/zip/yihui_demo.txt: -------------------------------------------------------------------------------- 1 | the original demo book by Yihui Xie 2 | -------------------------------------------------------------------------------- /inst/zip/nte_zh.txt: -------------------------------------------------------------------------------- 1 | a template from Nothing to envy, in Chinese 2 | -------------------------------------------------------------------------------- /inst/zip/thesis_zju_zh.txt: -------------------------------------------------------------------------------- 1 | thesis of Zhejiang Uni., in Chinese 2 | -------------------------------------------------------------------------------- /inst/yml/_output_html_document2.yml: -------------------------------------------------------------------------------- 1 | bookdown::html_document2: default 2 | -------------------------------------------------------------------------------- /inst/yml/_output_word_document2.yml: -------------------------------------------------------------------------------- 1 | bookdown::word_document2: default 2 | -------------------------------------------------------------------------------- /inst/zip/chemistry.txt: -------------------------------------------------------------------------------- 1 | book with chemical molecular formulae and equations 2 | -------------------------------------------------------------------------------- /inst/zip/thesis_mypku_zh.txt: -------------------------------------------------------------------------------- 1 | a simple template for thesis of Peking Uni., in Chinese 2 | -------------------------------------------------------------------------------- /inst/zip/thesis_pku_zh.txt: -------------------------------------------------------------------------------- 1 | a complete version of thesis of Peking Univ., in Chinese 2 | -------------------------------------------------------------------------------- /fonts/fonts.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/fonts/fonts.zip -------------------------------------------------------------------------------- /inst/zip/docsens.txt: -------------------------------------------------------------------------------- 1 | a template from the book Lokal lagring og bruk av sensitive data 2 | -------------------------------------------------------------------------------- /inst/zip/igo.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/igo.zip -------------------------------------------------------------------------------- /inst/zip/rbasics.txt: -------------------------------------------------------------------------------- 1 | a template from the book Getting used to R, RStudio, and R Markdown 2 | -------------------------------------------------------------------------------- /inst/zip/mail.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/mail.zip -------------------------------------------------------------------------------- /inst/zip/musix.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/musix.zip -------------------------------------------------------------------------------- /inst/zip/poem.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/poem.zip -------------------------------------------------------------------------------- /inst/zip/skak.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/skak.zip -------------------------------------------------------------------------------- /inst/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/images/logo.png -------------------------------------------------------------------------------- /inst/images/mail.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/images/mail.pdf -------------------------------------------------------------------------------- /inst/zip/article.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/article.zip -------------------------------------------------------------------------------- /inst/zip/calendar.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/calendar.zip -------------------------------------------------------------------------------- /inst/zip/cchess.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/cchess.zip -------------------------------------------------------------------------------- /inst/zip/dnd_dev.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/dnd_dev.zip -------------------------------------------------------------------------------- /inst/zip/docsens.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/docsens.zip -------------------------------------------------------------------------------- /inst/zip/guitar.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/guitar.zip -------------------------------------------------------------------------------- /inst/zip/journal.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/journal.zip -------------------------------------------------------------------------------- /inst/zip/nonpar.txt: -------------------------------------------------------------------------------- 1 | a book template from the book A short course on nonparametric curve estimation 2 | -------------------------------------------------------------------------------- /inst/zip/nonpar.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/nonpar.zip -------------------------------------------------------------------------------- /inst/zip/nte_zh.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/nte_zh.zip -------------------------------------------------------------------------------- /inst/zip/poster.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/poster.zip -------------------------------------------------------------------------------- /inst/zip/rbasics.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/rbasics.zip -------------------------------------------------------------------------------- /inst/zip/yihui_zh.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/yihui_zh.zip -------------------------------------------------------------------------------- /inst/zip/article_zh.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/article_zh.zip -------------------------------------------------------------------------------- /inst/zip/chemistry.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/chemistry.zip -------------------------------------------------------------------------------- /inst/zip/discussion.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/discussion.zip -------------------------------------------------------------------------------- /inst/zip/thesis_ubt.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/thesis_ubt.zip -------------------------------------------------------------------------------- /inst/zip/yihui_crc.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/yihui_crc.zip -------------------------------------------------------------------------------- /inst/zip/yihui_demo.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/yihui_demo.zip -------------------------------------------------------------------------------- /inst/zip/yihui_mini.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/yihui_mini.zip -------------------------------------------------------------------------------- /inst/zip/article_mdpi.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/article_mdpi.zip -------------------------------------------------------------------------------- /inst/zip/chemistry_zh.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/chemistry_zh.zip -------------------------------------------------------------------------------- /inst/zip/thesis_pku_zh.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/thesis_pku_zh.zip -------------------------------------------------------------------------------- /inst/zip/thesis_zju_zh.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/thesis_zju_zh.zip -------------------------------------------------------------------------------- /inst/zip/thesis_classic.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/thesis_classic.zip -------------------------------------------------------------------------------- /inst/zip/thesis_mypku_zh.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/zip/thesis_mypku_zh.zip -------------------------------------------------------------------------------- /inst2/showcase/musixskak.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/musixskak.jpg -------------------------------------------------------------------------------- /inst/images/bookdownplus-logo.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/images/bookdownplus-logo.pdf -------------------------------------------------------------------------------- /inst/images/bookdownplus-logopic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/images/bookdownplus-logopic.pdf -------------------------------------------------------------------------------- /inst/images/bookdownplus-logotxt.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst/images/bookdownplus-logotxt.pdf -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_mail.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_mail.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_poem.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_poem.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_skak.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_skak.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_guitar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_guitar.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_nonpar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_nonpar.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_nte_zh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_nte_zh.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_poster.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_poster.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_article.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_article.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_calendar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_calendar.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_chemistry.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_chemistry.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_dnd_dev.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_dnd_dev.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_docsens.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_docsens.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_journal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_journal.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_rbasics.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_rbasics.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_yihui_crc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_yihui_crc.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_yihui_zh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_yihui_zh.jpg -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | archive/ 4 | readme.* 5 | updates.* 6 | help/ 7 | fonts/ 8 | gitsync_bookdownplus.bat 9 | inst2/ -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_article_zh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_article_zh.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_discussion.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_discussion.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_thesis_pku.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_thesis_pku.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_thesis_ubt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_thesis_ubt.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_thesis_zju.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_thesis_zju.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_yihui_demo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_yihui_demo.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_yihui_mini.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_yihui_mini.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_article_mdpi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_article_mdpi.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_thesis_classic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_thesis_classic.jpg -------------------------------------------------------------------------------- /inst2/showcase/bookdownplus_thesis_mypku.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DataXujing/bookdownplus/master/inst2/showcase/bookdownplus_thesis_mypku.jpg -------------------------------------------------------------------------------- /inst/yml/_output_gitbook.yml: -------------------------------------------------------------------------------- 1 | bookdown::gitbook: 2 | css: style/gitbook.css 3 | config: 4 | toc: 5 | collapse: none 6 | after: | 7 |
  • Supported by bookdownplus
  • 8 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(bd) 4 | export(bookdownplus) 5 | export(mail_bodysize) 6 | export(mail_font) 7 | export(mail_fontsize) 8 | export(mail_style) 9 | export(mail_theme) 10 | export(more_output) 11 | export(poster_theme) 12 | export(share) 13 | export(template) 14 | importFrom(utils,download.file) 15 | importFrom(utils,unzip) 16 | -------------------------------------------------------------------------------- /inst/proj/bookdownplus: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: XeLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Website 19 | -------------------------------------------------------------------------------- /inst/yml/_output.yml: -------------------------------------------------------------------------------- 1 | bookdown::word_document2: default 2 | bookdown::epub_book: default 3 | bookdown::gitbook: 4 | css: style/gitbook.css 5 | config: 6 | toc: 7 | collapse: none 8 | before: | 9 |
  • Homepage'
  • 10 | after: | 11 |
  • Supported by bookdownplus
  • 12 | -------------------------------------------------------------------------------- /inst2/style/gitbook.css: -------------------------------------------------------------------------------- 1 | p.caption { 2 | color: #777; 3 | margin-top: 10px; 4 | } 5 | p code { 6 | white-space: inherit; 7 | } 8 | pre { 9 | word-break: normal; 10 | word-wrap: normal; 11 | } 12 | pre code { 13 | white-space: inherit; 14 | } 15 | p.flushright { 16 | text-align: right; 17 | } 18 | blockquote > p:last-child { 19 | text-align: right; 20 | } 21 | blockquote > p:first-child { 22 | text-align: inherit; 23 | } 24 | -------------------------------------------------------------------------------- /man/bd.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fun.R 3 | \name{bd} 4 | \alias{bd} 5 | \title{Show demos} 6 | \usage{ 7 | bd(x = template()[-which(template() == "poster")], mail_all = FALSE) 8 | } 9 | \arguments{ 10 | \item{x}{NA or character, templates to show} 11 | 12 | \item{mail_all}{logical} 13 | } 14 | \value{ 15 | demo files 16 | } 17 | \description{ 18 | Show demos 19 | } 20 | \examples{ 21 | bd(x = NA) 22 | } 23 | -------------------------------------------------------------------------------- /bookdownplus.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageInstallArgs: -v && Rscript -e "Rd2roxygen::rab(install=TRUE)" 20 | PackageCheckArgs: --as-cran 21 | -------------------------------------------------------------------------------- /man/mail_font.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fun.R 3 | \name{mail_font} 4 | \alias{mail_font} 5 | \title{Available fonts for mail body} 6 | \usage{ 7 | mail_font(dataframe = FALSE) 8 | } 9 | \arguments{ 10 | \item{dataframe}{logical. FALSE by default. whether return a vector or a data frame.} 11 | } 12 | \value{ 13 | a vector or a dataframe. 14 | } 15 | \description{ 16 | Available fonts for mail body 17 | } 18 | \examples{ 19 | mail_font() 20 | } 21 | -------------------------------------------------------------------------------- /man/template.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fun.R 3 | \name{template} 4 | \alias{template} 5 | \title{Available templates} 6 | \usage{ 7 | template(dataframe = FALSE) 8 | } 9 | \arguments{ 10 | \item{dataframe}{logical. FALSE by default. whether return a vector or a data frame.} 11 | } 12 | \value{ 13 | a vector or a dataframe displaying available templates. 14 | } 15 | \description{ 16 | Available templates 17 | } 18 | \examples{ 19 | template() 20 | } 21 | -------------------------------------------------------------------------------- /man/mail_style.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fun.R 3 | \name{mail_style} 4 | \alias{mail_style} 5 | \title{Available styles for mail template} 6 | \usage{ 7 | mail_style(dataframe = FALSE) 8 | } 9 | \arguments{ 10 | \item{dataframe}{logical. FALSE by default. whether return a vector or a data frame.} 11 | } 12 | \value{ 13 | a vector or a dataframe. 14 | } 15 | \description{ 16 | Available styles for mail template 17 | } 18 | \examples{ 19 | mail_style() 20 | } 21 | -------------------------------------------------------------------------------- /man/mail_theme.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fun.R 3 | \name{mail_theme} 4 | \alias{mail_theme} 5 | \title{Available themes for mail template} 6 | \usage{ 7 | mail_theme(dataframe = FALSE) 8 | } 9 | \arguments{ 10 | \item{dataframe}{logical. FALSE by default. whether return a vector or a data frame.} 11 | } 12 | \value{ 13 | a vector or a dataframe. 14 | } 15 | \description{ 16 | Available themes for mail template 17 | } 18 | \examples{ 19 | mail_theme() 20 | } 21 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * linguist-vendored 2 | *.R linguist-vendored=false 3 | 4 | # Auto detect text files and perform LF normalization 5 | * text=auto 6 | 7 | # Custom for Visual Studio 8 | *.cs diff=csharp 9 | 10 | # Standard to msysgit 11 | *.doc diff=astextplain 12 | *.DOC diff=astextplain 13 | *.docx diff=astextplain 14 | *.DOCX diff=astextplain 15 | *.dot diff=astextplain 16 | *.DOT diff=astextplain 17 | *.pdf diff=astextplain 18 | *.PDF diff=astextplain 19 | *.rtf diff=astextplain 20 | *.RTF diff=astextplain 21 | -------------------------------------------------------------------------------- /man/mail_bodysize.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fun.R 3 | \name{mail_bodysize} 4 | \alias{mail_bodysize} 5 | \title{Available fontsize for mail body} 6 | \usage{ 7 | mail_bodysize(dataframe = FALSE) 8 | } 9 | \arguments{ 10 | \item{dataframe}{logical. FALSE by default. whether return a vector or a data frame.} 11 | } 12 | \value{ 13 | a vector or a dataframe. 14 | } 15 | \description{ 16 | Available fontsize for mail body 17 | } 18 | \examples{ 19 | mail_bodysize() 20 | } 21 | -------------------------------------------------------------------------------- /man/mail_fontsize.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fun.R 3 | \name{mail_fontsize} 4 | \alias{mail_fontsize} 5 | \title{Available fontsize for mail template} 6 | \usage{ 7 | mail_fontsize(dataframe = FALSE) 8 | } 9 | \arguments{ 10 | \item{dataframe}{logical. FALSE by default. whether return a vector or a data frame.} 11 | } 12 | \value{ 13 | a vector or a dataframe. 14 | } 15 | \description{ 16 | Available fontsize for mail template 17 | } 18 | \examples{ 19 | mail_fontsize() 20 | } 21 | -------------------------------------------------------------------------------- /man/more_output.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fun.R 3 | \name{more_output} 4 | \alias{more_output} 5 | \title{Available output formats besides pdf_book} 6 | \usage{ 7 | more_output(dataframe = FALSE) 8 | } 9 | \arguments{ 10 | \item{dataframe}{logical. FALSE by default. whether return a vector or a data frame.} 11 | } 12 | \value{ 13 | a vector or a dataframe. 14 | } 15 | \description{ 16 | Available output formats besides pdf_book 17 | } 18 | \examples{ 19 | more_output() 20 | } 21 | -------------------------------------------------------------------------------- /man/poster_theme.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fun.R 3 | \name{poster_theme} 4 | \alias{poster_theme} 5 | \title{Available themes for poster templatemail body} 6 | \usage{ 7 | poster_theme(dataframe = FALSE) 8 | } 9 | \arguments{ 10 | \item{dataframe}{logical. FALSE by default. whether return a vector or a data frame.} 11 | } 12 | \value{ 13 | a vector or a dataframe. 14 | } 15 | \description{ 16 | Available themes for poster templatemail body 17 | } 18 | \examples{ 19 | poster_theme() 20 | } 21 | -------------------------------------------------------------------------------- /man/share.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fun.R 3 | \name{share} 4 | \alias{share} 5 | \title{Prepare a template to contribute to bookdownplus} 6 | \usage{ 7 | share(template_name = "new", bodyfile = "body.Rmd", indexfile = "index.Rmd", 8 | texfile = "t.tex") 9 | } 10 | \arguments{ 11 | \item{template_name}{character. tempalte name.} 12 | 13 | \item{bodyfile}{character. name of the body file.} 14 | 15 | \item{indexfile}{character. name of the index file.} 16 | 17 | \item{texfile}{character. name of the texfile} 18 | } 19 | \value{ 20 | organzed folders and files. 21 | } 22 | \description{ 23 | Prepare a template to contribute to bookdownplus 24 | } 25 | \examples{ 26 | share() 27 | } 28 | -------------------------------------------------------------------------------- /inst/proj/index.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "R bookdownplus: Authoring Articles, Mails, Guitar Chords, Chemical Molecular Formulae and Equations with R bookdown" 3 | author: "Peng Zhao, Samwell Tarly and Lyanna Mormont*" 4 | date: "" 5 | output: 6 | bookdown::pdf_book: 7 | template: tex/template_new.tex 8 | keep_tex: yes 9 | citation_package: natbib 10 | # latex_engine: xelatex 11 | toc_depth: 3 12 | toc_unnumbered: no 13 | toc_appendix: yes 14 | pandoc_args: --chapters 15 | quote_footer: ["\\begin{flushright}", "\\end{flushright}"] 16 | bibliography: [bib/bib.bib] 17 | biblio-style: apalike 18 | link-citations: yes 19 | colorlinks: no 20 | # toc: no 21 | lot: no 22 | lof: no 23 | site: bookdown::bookdown_site 24 | --- 25 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: bookdownplus 2 | Version: 1.4.6 3 | Date: 2018-06-10 4 | Title: Generate Assorted Books and Documents with R 'bookdown' Package 5 | Author: Peng Zhao 6 | Maintainer: Peng Zhao 7 | Depends: R (>= 3.1.0) 8 | Imports: 9 | knitr (>= 1.15), 10 | bookdown (>= 0.3.17), 11 | yaml (>= 2.1.14) 12 | Suggests: 13 | Description: A collection and selector of R 'bookdown' templates. 'bookdownplus' helps you write academic journal articles, guitar books, chemical equations, mails, calendars, and diaries. R 'bookdownplus' extends the features of 'bookdown', and simplifies the procedure. Users only have to choose a template, clarify the book title and author name, and then focus on writing the text. No need to struggle in 'YAML' and 'LaTeX'. 14 | License: GPL 15 | URL: https://github.com/pzhaonet/bookdownplus 16 | BugReports: https://github.com/pzhaonet/bookdownplus/issues 17 | Roxygen: list(markdown = TRUE) 18 | RoxygenNote: 6.0.1 19 | NeedsCompilation: no 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | archive/ 2 | .Rproj.user/ 3 | readme.Rmd 4 | help/ 5 | .Rbuildignore 6 | gitsync_bookdownplus.bat 7 | _*.* 8 | 9 | # Windows image file caches 10 | Thumbs.db 11 | ehthumbs.db 12 | 13 | # Folder config file 14 | Desktop.ini 15 | 16 | # Recycle Bin used on file shares 17 | $RECYCLE.BIN/ 18 | 19 | # Windows Installer files 20 | *.cab 21 | *.msi 22 | *.msm 23 | *.msp 24 | 25 | # Windows shortcuts 26 | *.lnk 27 | 28 | # ========================= 29 | # Operating System Files 30 | # ========================= 31 | 32 | # OSX 33 | # ========================= 34 | 35 | .DS_Store 36 | .AppleDouble 37 | .LSOverride 38 | 39 | # Thumbnails 40 | ._* 41 | 42 | # Files that might appear in the root of a volume 43 | .DocumentRevisions-V100 44 | .fseventsd 45 | .Spotlight-V100 46 | .TemporaryItems 47 | .Trashes 48 | .VolumeIcon.icns 49 | 50 | # Directories potentially created on remote AFP share 51 | .AppleDB 52 | .AppleDesktop 53 | Network Trash Folder 54 | Temporary Items 55 | .apdisk 56 | -------------------------------------------------------------------------------- /DESCRIPTION.bak: -------------------------------------------------------------------------------- 1 | Package: bookdownplus 2 | Version: 1.4.3 3 | Date: 2018-02-05 4 | Title: Generate Assorted Books and Documents with R 'bookdown' Package 5 | Author: Peng Zhao 6 | Maintainer: Peng Zhao 7 | Depends: R (>= 3.1.0) 8 | Imports: 9 | knitr (>= 1.15), 10 | bookdown (>= 0.3.17), 11 | yaml (>= 2.1.14) 12 | Suggests: 13 | Description: A collection and selector of R 'bookdown' templates. 'bookdownplus' helps you write academic journal articles, guitar books, chemical equations, mails, calendars, and diaries. R 'bookdownplus' extends the features of 'bookdown', and simplifies the procedure. Users only have to choose a template, clarify the book title and author name, and then focus on writing the text. No need to struggle in 'YAML' and 'LaTeX'. 14 | License: GPL 15 | URL: https://github.com/pzhaonet/bookdownplus 16 | BugReports: https://github.com/pzhaonet/bookdownplus/issues 17 | Roxygen: list(markdown = TRUE) 18 | RoxygenNote: 6.0.1 19 | NeedsCompilation: no 20 | -------------------------------------------------------------------------------- /inst2/style/tweaklist.sty: -------------------------------------------------------------------------------- 1 | %% start of file `tweaklist.sty'. 2 | %% Original by Jakob Schiøtz, downloaded from http://dcwww.camd.dtu.dk/~schiotz/comp/LatexTips/tweaklist.sty; not found on ctan. 3 | %% Modified by Xavier Danaux (xdanaux@gmail.com). 4 | % 5 | % The tweaklist.sty package redefines the itemize, enumerate and description packages, so that all parameters can be adjusted. 6 | % This was done by copying the original definitions, and adding "hook commands" that are executed when entering the environment. 7 | % The hook commands are initially empty, but can be redefined with \renewcommand. 8 | % 9 | % This work may be distributed and/or modified under the 10 | % conditions of the LaTeX Project Public License version 1.3c, 11 | % available at http://www.latex-project.org/lppl/. 12 | 13 | 14 | % hooks for the itemize environment 15 | \def\itemhook{} 16 | \def\itemhooki{} 17 | \def\itemhookii{} 18 | \def\itemhookiii{} 19 | \def\itemhookiv{} 20 | % hooks for the enumerate environment 21 | \def\enumhook{} 22 | \def\enumhooki{} 23 | \def\enumhookii{} 24 | \def\enumhookiii{} 25 | \def\enumhookiv{} 26 | % hook for the description environment 27 | \def\deschook{} 28 | % original environment definitions, with hooks added 29 | \def\enumerate{% 30 | \ifnum \@enumdepth >\thr@@\@toodeep\else 31 | \advance\@enumdepth\@ne 32 | \edef\@enumctr{enum\romannumeral\the\@enumdepth}% 33 | \expandafter 34 | \list 35 | \csname label\@enumctr\endcsname 36 | {% 37 | \enumhook \csname enumhook\romannumeral\the\@enumdepth\endcsname% 38 | \usecounter\@enumctr\def\makelabel##1{\hss\llap{##1}}% 39 | }% 40 | \fi} 41 | \def\itemize{% 42 | \ifnum \@itemdepth >\thr@@\@toodeep\else 43 | \advance\@itemdepth\@ne 44 | \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}% 45 | \expandafter 46 | \list 47 | \csname\@itemitem\endcsname 48 | {% 49 | \itemhook \csname itemhook\romannumeral\the\@itemdepth\endcsname% 50 | \def\makelabel##1{\hss\llap{##1}}% 51 | }% 52 | \fi} 53 | \newenvironment{description} 54 | {\list{}{\deschook\labelwidth\z@ \itemindent-\leftmargin 55 | \let\makelabel\descriptionlabel}} 56 | {\endlist} 57 | -------------------------------------------------------------------------------- /inst/proj/body.Rmd: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | The R package `bookdownplus` [@R-bookdownplus] is an extension of `bookdown` [@R-bookdown]. It is a collection of 4 | multiple templates on the basis of LaTeX, which are tailored so that I can work happily under the umbrella of `bookdown`. `bookdownplus` helps you write academic journal articles, guitar books, chemical equations, mails, calendars, and diaries. 5 | 6 | # Features 7 | 8 | `bookdownplus` extends the features of `bookdown`, and simplifies the procedure. Users only have to choose a template, clarify the book title and author name, and then focus on writing the text. No need to struggle in YAML and LaTeX. 9 | 10 | With `bookdownplus` users can 11 | 12 | - record guitar chords, 13 | 14 | - write a mail in an elegant layout, 15 | 16 | - write a laboratory journal, or a personal diary, 17 | 18 | - draw a monthly or weekly or conference calendar, 19 | 20 | - and, of course, write academic articles in your favourite way, 21 | 22 | - with chemical molecular formulae and equations, 23 | 24 | - even in Chinese, 25 | 26 | - and more wonders will come soon. 27 | 28 | Full documentation can be found in the book [R bookdownplus Textbook](https://bookdown.org/baydap/bookdownplus). The webpage looks so-so, while the [pdf file](https://bookdown.org/baydap/bookdownplus/bookdownplus.pdf) might give you a little surprise. 29 | 30 | # Quick start 31 | 32 | Although this section might not be the latest version, the general idea won't change. Please see [R bookdownplus Textbook](https://bookdown.org/baydap/bookdownplus) to keep up with the update. 33 | 34 | ## Preparation 35 | 36 | Before starting, you have to install R, RStudio, bookdown package, and 37 | other software and packages (i.e. Pandoc, LaTeX, rmarkdown, rticle, 38 | knitr, etc.) which bookdown depends on. See the official [manual](https://bookdown.org/yihui/bookdown/) of 39 | bookdown for details. Additionally, if you want to produce a poster, phython must be installed before using, and the path of phython might have to be added to the environmental variables for Windows users. 40 | 41 | ## Installation 42 | 43 | ``` 44 | install.package("bookdownplus") 45 | # or 46 | devtools:: 47 | install_github("pzhaonet/bookdownplus") 48 | ``` 49 | 50 | ## Generate demo files 51 | 52 | Run the following codes, and you will get some files (e.g. `index.Rmd`, `body.Rmd`, `bookdownplus.Rproj`) and folders in your working directory. 53 | 54 | ``` 55 | getwd() # this is your working directory. run setwd() to change it. 56 | bookdownplus::bookdownplus() 57 | ``` 58 | 59 | ## Build a demo book 60 | 61 | Now open `bookdownplus.Rproj` with RStudio, and press `ctrl+shift+b` to compile it. Your will get a book file named `*.pdf` in `_book/`folder. 62 | 63 | ## Write your own 64 | 65 | Write your own text in `index.Rmd` and `body.Rmd`, and build your own lovely book. 66 | 67 | ## More outputs 68 | 69 | By default, the book is in a pdf file. From 'bookdownplus' 1.0.3, users can get more output formats, including 'word', 'html' and 'epub'. Run: 70 | 71 | ``` 72 | bookdownplus:: 73 | bookdownplus(template = 'article', 74 | more_output = c('html', 'word', 'epub')) 75 | ``` 76 | 77 | ## Recommendations 78 | 79 | I have been developing some other packages, which bring more features into 'bookdown', such as: 80 | 81 | - mindr [@R-mindr], which can extract the outline of your book and turn it into a mind map, and 82 | 83 | - pinyin [@R-pinyin], which can automatically generate ['{#ID}'](https://bookdown.org/yihui/bookdown/cross-references.html) of the chapter headers even if there are Chinese characters in them. 84 | 85 | Both of them have been released on CRAN and can be installed via: 86 | 87 | ``` 88 | install.packages('mindr') 89 | install.packages('pinyin') 90 | ``` 91 | 92 | Enjoy your bookdowning! 93 | 94 | ## Models 95 | 96 | Eq. \@ref(eq:mc2) is an equation. 97 | 98 | \begin{equation} 99 | E = mc^2 100 | (\#eq:mc2) 101 | \end{equation} 102 | 103 | It can be written as $E = mc^2$. 104 | 105 | 106 | # Results 107 | 108 | Fig. \@ref(fig:fig1) psum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 109 | 110 | ```{r fig1, fig.cap='caption', out.width='80%', fig.align='center', echo=FALSE} 111 | plot(cars) 112 | ``` 113 | 114 | Tab. \@ref(tab:tab1) psum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 115 | 116 | ```{r tab1, tidy=FALSE, echo=FALSE} 117 | knitr::kable( 118 | head(iris, 20), caption = 'Here is a nice table!', 119 | booktabs = TRUE 120 | ) 121 | ``` 122 | 123 | # Conclusions 124 | 125 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum 126 | -------------------------------------------------------------------------------- /inst2/tex/template_default.tex: -------------------------------------------------------------------------------- 1 | \documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$$if(papersize)$$papersize$,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{$documentclass$} 2 | $if(fontfamily)$ 3 | \usepackage{$fontfamily$} 4 | $else$ 5 | \usepackage{lmodern} 6 | $endif$ 7 | $if(linestretch)$ 8 | \usepackage{setspace} 9 | \setstretch{$linestretch$} 10 | $endif$ 11 | \usepackage{amssymb,amsmath} 12 | \usepackage{ifxetex,ifluatex} 13 | \usepackage{fixltx2e} % provides \textsubscript 14 | \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex 15 | \usepackage[T1]{fontenc} 16 | \usepackage[utf8]{inputenc} 17 | $if(euro)$ 18 | \usepackage{eurosym} 19 | $endif$ 20 | \else % if luatex or xelatex 21 | \ifxetex 22 | \usepackage{mathspec} 23 | \usepackage{xltxtra,xunicode} 24 | \else 25 | \usepackage{fontspec} 26 | \fi 27 | \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase} 28 | \newcommand{\euro}{€} 29 | $if(mainfont)$ 30 | \setmainfont{$mainfont$} 31 | $endif$ 32 | $if(sansfont)$ 33 | \setsansfont{$sansfont$} 34 | $endif$ 35 | $if(monofont)$ 36 | \setmonofont[Mapping=tex-ansi]{$monofont$} 37 | $endif$ 38 | $if(mathfont)$ 39 | \setmathfont(Digits,Latin,Greek){$mathfont$} 40 | $endif$ 41 | \fi 42 | % use upquote if available, for straight quotes in verbatim environments 43 | \IfFileExists{upquote.sty}{\usepackage{upquote}}{} 44 | % use microtype if available 45 | \IfFileExists{microtype.sty}{% 46 | \usepackage{microtype} 47 | \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts 48 | }{} 49 | $if(geometry)$ 50 | \usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry} 51 | $endif$ 52 | $if(lang)$ 53 | \ifxetex 54 | \usepackage{polyglossia} 55 | \setmainlanguage{$mainlang$} 56 | \else 57 | \usepackage[shorthands=off,$lang$]{babel} 58 | \fi 59 | $endif$ 60 | $if(natbib)$ 61 | \usepackage{natbib} 62 | \bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$} 63 | $endif$ 64 | $if(biblatex)$ 65 | \usepackage[$if(biblio-style)$style=$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex} 66 | $for(bibliography)$ 67 | \addbibresource{$bibliography$} 68 | $endfor$ 69 | $endif$ 70 | $if(listings)$ 71 | \usepackage{listings} 72 | $endif$ 73 | $if(lhs)$ 74 | \lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{} 75 | $endif$ 76 | $if(highlighting-macros)$ 77 | $highlighting-macros$ 78 | $endif$ 79 | $if(verbatim-in-note)$ 80 | \usepackage{fancyvrb} 81 | \VerbatimFootnotes 82 | $endif$ 83 | $if(tables)$ 84 | \usepackage{longtable,booktabs} 85 | $endif$ 86 | $if(graphics)$ 87 | \usepackage{graphicx} 88 | \makeatletter 89 | \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi} 90 | \def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi} 91 | \makeatother 92 | % Scale images if necessary, so that they will not overflow the page 93 | % margins by default, and it is still possible to overwrite the defaults 94 | % using explicit options in \includegraphics[width, height, ...]{} 95 | \setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio} 96 | $endif$ 97 | \ifxetex 98 | \usepackage[setpagesize=false, % page size defined by xetex 99 | unicode=false, % unicode breaks when used with xetex 100 | xetex]{hyperref} 101 | \else 102 | \usepackage[unicode=true]{hyperref} 103 | \fi 104 | \hypersetup{breaklinks=true, 105 | bookmarks=true, 106 | pdfauthor={$author-meta$}, 107 | pdftitle={$title-meta$}, 108 | colorlinks=true, 109 | citecolor=$if(citecolor)$$citecolor$$else$blue$endif$, 110 | urlcolor=$if(urlcolor)$$urlcolor$$else$blue$endif$, 111 | linkcolor=$if(linkcolor)$$linkcolor$$else$magenta$endif$, 112 | pdfborder={0 0 0}} 113 | \urlstyle{same} % don't use monospace font for urls 114 | $if(links-as-notes)$ 115 | % Make links footnotes instead of hotlinks: 116 | \renewcommand{\href}[2]{#2\footnote{\url{#1}}} 117 | $endif$ 118 | $if(strikeout)$ 119 | \usepackage[normalem]{ulem} 120 | % avoid problems with \sout in headers with hyperref: 121 | \pdfstringdefDisableCommands{\renewcommand{\sout}{}} 122 | $endif$ 123 | \setlength{\parindent}{0pt} 124 | \setlength{\parskip}{6pt plus 2pt minus 1pt} 125 | \setlength{\emergencystretch}{3em} % prevent overfull lines 126 | $if(numbersections)$ 127 | \setcounter{secnumdepth}{5} 128 | $else$ 129 | \setcounter{secnumdepth}{0} 130 | $endif$ 131 | $if(verbatim-in-note)$ 132 | \VerbatimFootnotes % allows verbatim text in footnotes 133 | $endif$ 134 | 135 | %%% Use protect on footnotes to avoid problems with footnotes in titles 136 | \let\rmarkdownfootnote\footnote% 137 | \def\footnote{\protect\rmarkdownfootnote} 138 | 139 | %%% Change title format to be more compact 140 | \usepackage{titling} 141 | 142 | % Create subtitle command for use in maketitle 143 | \newcommand{\subtitle}[1]{ 144 | \posttitle{ 145 | \begin{center}\large#1\end{center} 146 | } 147 | } 148 | 149 | \setlength{\droptitle}{-2em} 150 | $if(title)$ 151 | \title{$title$} 152 | \pretitle{\vspace{\droptitle}\centering\huge} 153 | \posttitle{\par} 154 | $else$ 155 | \title{} 156 | \pretitle{\vspace{\droptitle}} 157 | \posttitle{} 158 | $endif$ 159 | $if(subtitle)$ 160 | \subtitle{$subtitle$} 161 | $endif$ 162 | 163 | $if(author)$ 164 | \author{$for(author)$$author$$sep$ \and $endfor$} 165 | $endif$ 166 | $if(institute)$ 167 | \providecommand{\institute}[1]{} 168 | \institute{$for(institute)$$institute$$sep$ \and $endfor$} 169 | $endif$ 170 | 171 | $if(date)$ 172 | \predate{\centering\large\emph} 173 | \postdate{\par} 174 | \date{$date$} 175 | $else$ 176 | \date{} 177 | \predate{}\postdate{} 178 | $endif$ 179 | 180 | $for(header-includes)$ 181 | $header-includes$ 182 | $endfor$ 183 | 184 | \begin{document} 185 | 186 | \maketitle 187 | 188 | $if(abstract)$ 189 | \begin{abstract} 190 | $abstract$ 191 | \end{abstract} 192 | $endif$ 193 | 194 | $for(include-before)$ 195 | $include-before$ 196 | 197 | $endfor$ 198 | $if(toc)$ 199 | { 200 | \hypersetup{linkcolor=black} 201 | \setcounter{tocdepth}{$toc-depth$} 202 | \tableofcontents 203 | } 204 | $endif$ 205 | $if(lot)$ 206 | \listoftables 207 | $endif$ 208 | $if(lof)$ 209 | \listoffigures 210 | $endif$ 211 | $body$ 212 | 213 | 214 | $if(natbib)$ 215 | $if(bibliography)$ 216 | $if(biblio-title)$ 217 | $if(book-class)$ 218 | \renewcommand\bibname{$biblio-title$} 219 | $else$ 220 | \renewcommand\refname{$biblio-title$} 221 | $endif$ 222 | $endif$ 223 | \bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$} 224 | $endif$ 225 | $endif$ 226 | $if(biblatex)$ 227 | \printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$ 228 | $endif$ 229 | 230 | $for(include-after)$ 231 | $include-after$ 232 | $endfor$ 233 | \end{document} 234 | -------------------------------------------------------------------------------- /inst2/style/newtxtext.sty: -------------------------------------------------------------------------------- 1 | \NeedsTeXFormat{LaTeX2e} 2 | 3 | \def\fileversion{1.521} 4 | \def\filedate{2017/03/11} 5 | \ProvidesPackage{newtxtext}[\filedate\space v\fileversion] 6 | 7 | \message{`newtxtext' v\fileversion, \filedate\space Text macros taking advantage of TeX-Gyre Termes fonts (msharpe)} 8 | \RequirePackage{fontaxes}% so we can have [bold] italic small caps 9 | 10 | \let\orig@footnote=\thefootnote 11 | \let\orig@makefnmark=\@makefnmark 12 | \newdimen\ntx@fs 13 | \RequirePackage{xkeyval,etoolbox} 14 | \renewcommand*{\rmdefault}{ntxtlf} % always TLF for math 15 | \renewcommand*{\familydefault}{\rmdefault} 16 | \def\useosf{\edef\ntx@figurestyle{osf}} 17 | \@onlypreamble\useosf 18 | \def\useproportional{\edef\ntx@figurealign{}} 19 | \@onlypreamble\useproportional 20 | 21 | \def\ntx@figurestyle{lf}% default is lining figure style 22 | \def\ntx@figurealign{t}% default is tabular figure alignment 23 | \newif\ifntx@defaultsups 24 | \newif\ifntx@adobesc 25 | \newif\ifntx@scosf 26 | \newif\ifntx@largesc 27 | %\newif\ifntx@babel 28 | %\ifdefined\bbl@version \ntx@babeltrue\fi 29 | \define@boolkey{ntx}{defaultsups}[true]{% 30 | \csname ntx@defaultsups#1\endcsname} 31 | \define@boolkey{ntx}{largesc}[true]{% 32 | \csname ntx@largesc#1\endcsname} 33 | \define@boolkey{ntx}{adobesc}[true]{% 34 | \csname ntx@adobesc#1\endcsname} 35 | \define@key{ntx}{babel}[true]{\relax}% keep, though no effect 36 | %\csname ntx@babel#1\endcsname} 37 | \newif\ifntx@thrm 38 | \define@key{ntx}{helvratio}[0.9]{\def\ntx@helvratio{#1}} 39 | \define@key{ntx}{scaled}[1.0]{\def\ntx@scaled{s*[#1]}% 40 | \def\ntx@scale{#1}\def\LGCscale{#1}} 41 | \setkeys{ntx}{helvratio} % set this first, at least to default 0.9 42 | \setkeys{ntx}{scaled} % get at least default 43 | 44 | \def\ntx@spc{.25em} 45 | \def\ntx@stretch{.2em} 46 | \def\ntx@shrink{.1em} 47 | \define@key{ntx}{spacing}[.25em]{\gdef\ntx@spc{#1}} 48 | \define@key{ntx}{stretch}[.2em]{\gdef\ntx@stretch{#1}} 49 | \define@key{ntx}{shrink}[.1em]{\gdef\ntx@shrink{#1}} 50 | 51 | 52 | \DeclareOption{lining}{\edef\ntx@figurestyle{lf}} 53 | \DeclareOption{lf}{\edef\ntx@figurestyle{lf}} 54 | \DeclareOption{theoremfont}{\ntx@thrmtrue} 55 | \DeclareOption{oldstyle}{\useosf} 56 | \DeclareOption{osf}{\useosf} 57 | \DeclareOption{tabular}{\edef\ntx@figurealign{t}} 58 | \DeclareOption{p}{\useproportional} 59 | \DeclareOption{proportional}{\useproportional} 60 | %\DeclareOption{sups}{\ntx@defaultsupsfalse} 61 | \DeclareOption{scosf}{\ntx@scosftrue} 62 | \DeclareOption{tighter}{% 63 | \gdef\ntx@spc{.25em}\gdef\ntx@stretch{.15em}\gdef\ntx@shrink{.06em}} 64 | \DeclareOption{looser}{% 65 | \gdef\ntx@spc{.3em}\gdef\ntx@stretch{.2em}\gdef\ntx@shrink{.15em} 66 | } 67 | \ExecuteOptions{lining,tabular} 68 | 69 | \DeclareOption*{% 70 | \begingroup 71 | \edef\x{\endgroup 72 | \noexpand\setkeys{ntx}{\CurrentOption}}% 73 | \x} 74 | 75 | \ProcessOptions* 76 | \def\ntx@spacing{% 77 | \fontdimen2\font=\ntx@spc 78 | \fontdimen3\font=\ntx@stretch 79 | \fontdimen4\font=\ntx@shrink 80 | } 81 | 82 | \@tempdima=\ntx@scale\p@\@tempdima=\ntx@helvratio\@tempdima% 83 | \edef\qhv@scale{\strip@pt\@tempdima} 84 | 85 | \RequirePackage[T1]{fontenc} 86 | \RequirePackage[full]{textcomp} 87 | \DeclareRobustCommand{\sustyle}{% 88 | \not@math@alphabet\sustyle\relax 89 | \fontfamily{ntxsups}\selectfont} 90 | 91 | \ifntx@scosf % 92 | \DeclareRobustCommand{\textsc}[1]{% 93 | {\fontfamily{ntx\ntx@figurealign osf}\scshape\selectfont #1}% 94 | }\fi% use OsF in small caps 95 | 96 | \DeclareRobustCommand{\lfstyle}{% 97 | \not@math@alphabet\lfstyle\relax 98 | \fontfamily{ntxlf}\selectfont % 99 | }% to get lf 100 | \DeclareRobustCommand{\tlfstyle}{% 101 | \not@math@alphabet\tlfstyle\relax 102 | \fontfamily{ntxtlf}\selectfont % 103 | }% to get tlf 104 | \DeclareRobustCommand{\osfstyle}{% 105 | \not@math@alphabet\osfstyle\relax 106 | \fontfamily{ntxosf}\selectfont % 107 | }% to get osf 108 | \DeclareRobustCommand{\tosfstyle}{% 109 | \not@math@alphabet\tosfstyle\relax 110 | \fontfamily{ntxtosf}\selectfont % 111 | }% to get tosf 112 | \DeclareRobustCommand{\textlf}[1]{% 113 | {\lfstyle #1}% 114 | }% to get lf 115 | \DeclareRobustCommand{\texttlf}[1]{% 116 | {\tlfstyle #1}% 117 | }% to get tlf 118 | \DeclareRobustCommand{\textosf}[1]{% 119 | {\osfstyle #1}% 120 | }% to get osf 121 | \DeclareRobustCommand{\texttosf}[1]{% 122 | {\tosfstyle #1}% 123 | }% to get tosf 124 | \DeclareRobustCommand{\textsu}[1]{% 125 | {\sustyle #1}% 126 | }% to get sup style 127 | 128 | \ifntx@thrm 129 | %\RequirePackage{amsmath,amsthm} % in case of theoremfont 130 | \ifdefined\newtheoremstyle %amsthm and ntheorem, not theorem.sty 131 | \@ifpackageloaded{ntheorem}\relax{% 132 | \newtheoremstyle{plain} 133 | {\medskipamount} % ABOVESPACE, was \topsep 134 | {\medskipamount} % BELOWSPACE, was \topsep 135 | {\slshape} % BODYFONT--\slshape is defined to be \itshape with upright figures and punctuation 136 | {} % INDENT (empty value is the same as 0pt) 137 | {\bfseries} % HEADFONT--you may want to add \tlfstyle so the number is tab lining, regardless of text figure selection 138 | {.} % HEADPUNCT 139 | {5pt plus 1pt minus 1pt} % HEADSPACE 140 | {} % CUSTOM-HEAD-SPEC\newtheorem{thm}{Theorem}[section] 141 | } % end @ifpackageloaded 142 | \fi% 143 | \fi 144 | %\DeclareTextFontCommand{\textsu}{\sustyle} 145 | %\def\@makefnmark{\ifx \thefootnote\orig@footnote \hbox{\sustyle\hspace*{.04em}\@thefnmark}\else\orig@makefnmark\fi} 146 | \ifntx@defaultsups % 147 | \else 148 | \def\f@@tn@te{footnote} 149 | \def\@makefnmark{% 150 | \ifx\@mpfn\f@@tn@te% footnote not in a minipage 151 | \ifx\thefootnote\orig@footnote% 152 | \hbox{\sustyle\hspace*{.04em}\@thefnmark\hspace*{.03em}}% 153 | \else% 154 | \orig@makefnmark% 155 | \fi 156 | \else% footnote in a minipage 157 | % \ntx@fs=\f@size\p@ 158 | % \ntx@fs=1.05\ntx@fs 159 | %\hbox{{\itshape\sustyle\fontsize{\strip@pt\ntx@fs}{12}\selectfont \@thefnmark\hspace*{.1em}}}% 160 | \orig@makefnmark% 161 | \fi} 162 | \fi 163 | 164 | %%%%%%%%%%%%%%%%%%%%%% 165 | % Text Serif (Times) % 166 | %%%%%%%%%%%%%%%%%%%%%% 167 | 168 | %\renewcommand*{\rmdefault}{ntxr\ntx@style} 169 | 170 | %\DeclareSymbolFont{operators}{OT1}{txr}{m}{n} 171 | %\SetSymbolFont{operators}{bold}{OT1}{txr}{bx}{n} 172 | %\def\operator@font{\mathgroup\symoperators} 173 | % 174 | %\DeclareSymbolFont{italic}{OT1}{txr}{m}{it} 175 | %\SetSymbolFont{italic}{bold}{OT1}{txr}{bx}{it} 176 | % 177 | %\DeclareSymbolFontAlphabet{\mathrm}{operators} 178 | %\DeclareMathAlphabet{\mathbf}{OT1}{txr}{bx}{n} 179 | %\DeclareMathAlphabet{\mathit}{OT1}{txr}{m}{it} 180 | %\SetMathAlphabet{\mathit}{bold}{OT1}{txr}{bx}{it} 181 | 182 | 183 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 184 | % Text Sans Serif (based on Helvetica) % 185 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 186 | 187 | 188 | \renewcommand*{\sfdefault}{qhv} 189 | 190 | %\DeclareMathAlphabet{\mathsf}{OT1}{txss}{m}{n} 191 | %\SetMathAlphabet{\mathsf}{bold}{OT1}{txss}{b}{n} 192 | 193 | 194 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 195 | % Text (Monospaced) Typewriter % 196 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 197 | 198 | \renewcommand{\ttdefault}{ntxtt} 199 | 200 | %\DeclareMathAlphabet{\mathtt}{OT1}{txtt}{m}{n} 201 | %\SetMathAlphabet{\mathtt}{bold}{OT1}{txtt}{b}{n} 202 | 203 | 204 | 205 | \def\re@DeclareTextSymbol#1#2#3{% 206 | \let#1=\undefined 207 | \DeclareTextSymbol{#1}{#2}{#3}} 208 | 209 | \def\re@DeclareMathSymbol#1#2#3#4{% 210 | \let#1=\undefined 211 | \DeclareMathSymbol{#1}{#2}{#3}{#4}} 212 | 213 | \re@DeclareTextSymbol{\L}{OT1}{138} 214 | \re@DeclareTextSymbol{\l}{OT1}{170} 215 | \re@DeclareTextSymbol{\textdollar}{OT1}{36} 216 | \re@DeclareTextSymbol{\textsterling}{OT1}{163} 217 | \re@DeclareMathSymbol{\mathsterling}{\mathord}{operators}{163} 218 | 219 | \DeclareTextComposite{\r}{OT1}{A}{197} 220 | \DeclareTextComposite{\r}{OT1}{a}{229} 221 | 222 | \re@DeclareTextSymbol{\textcent}{OT1}{162} 223 | \re@DeclareMathSymbol{\mathcent}{\mathord}{operators}{162} 224 | 225 | %%% Modification of T1 and LY1 encoding related stuff 226 | %%% 227 | 228 | \def\T@n@@nc@d@ng{T1} 229 | \def\T@n@@nc@d@ngM@cr@M@d{% 230 | \DeclareTextCommand{\k}{T1}[1]{{\ooalign{\hidewidth\char12\crcr##1}}}% 231 | } 232 | 233 | \def\LY@n@@nc@d@ng{LY1} 234 | \def\LY@n@@nc@d@ngM@cr@M@d{% 235 | \DeclareTextCommand{\k}{LY1}[1]{{\ooalign{\hidewidth\char7\crcr##1}}}% 236 | } 237 | 238 | \AtBeginDocument{% 239 | \ifx\encodingdefault\T@n@@nc@d@ng\T@n@@nc@d@ngM@cr@M@d\fi% 240 | \ifx\encodingdefault\LY@n@@nc@d@ng\LY@n@@nc@d@ngM@cr@M@d\fi% 241 | } 242 | 243 | %\ifntx@babel 244 | % \renewcommand*{\rmdefault}{ntx\ntx@figurealign% 245 | % \ntx@figurestyle} 246 | % \normalfont 247 | %\else 248 | \AtEndPreamble{% 249 | \renewcommand*{\rmdefault}{ntx\ntx@figurealign% 250 | \ntx@figurestyle} 251 | \normalfont} 252 | %\fi 253 | 254 | 255 | \endinput 256 | -------------------------------------------------------------------------------- /man/bookdownplus.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fun.R 3 | \name{bookdownplus} 4 | \alias{bookdownplus} 5 | \title{Create demo files for building books with R bookdown package.} 6 | \usage{ 7 | bookdownplus(template = "thesis_classic", more_output = NULL, 8 | title = "R bookdownplus", author = "Peng Zhao", render = FALSE, 9 | rproj = FALSE, output_name = NA, mail_from_address = "15 Robin Hood Lane", 10 | mail_from_town = "11758 Massapequa, Long Island, New York", 11 | mail_from_phone = "31415926", mail_from_mobile = "31415927", 12 | mail_from_fax = "31415928", mail_from_email = "test@test.test", 13 | mail_to_who = "recipient", mail_to_affiliation = "University of Innsbruck", 14 | mail_to_address = "recipient address", mail_to_town = "100000 Beijing, China", 15 | mail_opening = "Dear Sir or Madam,", mail_closing = "Yours faithfully,", 16 | mail_date = "25 June, 2017", mail_style = c("casual", "classic", 17 | "oldstyle", "banking")[1], mail_theme = c("blue", "orange", 18 | "green", "red", "purple", "grey", "black")[1], mail_font = c("sffamily", 19 | "calligra ")[1], mail_fontsize = c("10pt", "11pt", 20 | "12pt")[3], mail_bodysize = c("tiny", "scriptsize", 21 | "footnotesize", "small", "normalsize", "large", "Large", 22 | "LARGE", "huge", "Huge")[5], poster_email = "test@test.test", 23 | poster_institute = "Institute of Ecology, Univ. Innsbruck", 24 | poster_longinstitute = "Institute of Ecology, University of Innsbruck, Austria", 25 | poster_web = "pzhao.org", poster_logo = "images/logo.png", 26 | poster_backimg = "images/logo.png", poster_bibliofiles = "bib/bib.bib", 27 | poster_theme = c("eco", "ocean", "rose")[1]) 28 | } 29 | \arguments{ 30 | \item{template}{character. Choose a template for your book or doc. The default template is 'thesis_classic'. Available templates are (run \code{template()} for hints): 31 | \itemize{ 32 | \item 'article', academic article, 33 | \item 'article_mdpi', academic article by mdpi, 34 | \item 'article_zh', academic article in Chinese, 35 | \item 'calendar', monthly or weekly calendar, 36 | \item 'chemistry', book with chemical molecular formulae and equations 37 | \item 'chemistry_zh', chemistry book in Chinese, 38 | \item 'discussion', article in discussion format, 39 | \item 'guitar', book with guitar chords, 40 | \item 'journal', laboratory journal or personal diary, 41 | \item 'mail', personal or business mail, 42 | \item 'nte_zh', a template from Nothing to envy, in Chinese 43 | \item 'poem', poem book, 44 | \item 'thesis_classic' (default), classic thesis, 45 | \item 'thesis_mypku_zh', thesis of my Peking Uni., in Chinese, 46 | \item 'thesis_ubt', thesis of University of Bayreuth, 47 | \item 'thesis_zju_zh', thesis of Zhejiang Uni., in Chinese, 48 | \item 'yihui_demo', the original demo book by Yihui Xie, 49 | \item 'yihui_mini', a mini demo book by Yihui Xie, 50 | \item 'yihui_zh', the demo in Chinese by Yihui Xie, 51 | \item 'poster', poster. 52 | }} 53 | 54 | \item{more_output}{optional output formats besides pdf_book, which can be (run \code{more_output()} for hints): 55 | \itemize{ 56 | \item NULL (default) 57 | \item 'word_document2' 58 | \item 'html_document2' 59 | \item 'epub_book' 60 | \item 'gitbook' 61 | }} 62 | 63 | \item{title}{character. book title.} 64 | 65 | \item{author}{character. book author.} 66 | 67 | \item{render}{logical. whether to render automatically} 68 | 69 | \item{rproj}{logical. whether to created an .Rproj file automatically} 70 | 71 | \item{output_name}{chracter. the name of the output files. If NA (default), the template name will be used.} 72 | 73 | \item{mail_from_address}{character. sender's address (Street and No.) for mail template} 74 | 75 | \item{mail_from_town}{character. sender's town for mail template} 76 | 77 | \item{mail_from_phone}{character. sender's phone number for mail templae} 78 | 79 | \item{mail_from_mobile}{character. sender's mobile phone number for mail templae} 80 | 81 | \item{mail_from_fax}{character. sender's fax number for mail templae} 82 | 83 | \item{mail_from_email}{character. sender's email for mail template} 84 | 85 | \item{mail_to_who}{character. recipient's name for mail template} 86 | 87 | \item{mail_to_affiliation}{character. recipient's affiliation (institute, university, etc.) for mail template} 88 | 89 | \item{mail_to_address}{character. recipient's address (Street and No.) for mail template} 90 | 91 | \item{mail_to_town}{character. recipient's town for mail template} 92 | 93 | \item{mail_opening}{character. opening of the mail, such as 'Dear Thomas, '} 94 | 95 | \item{mail_closing}{character. closing of the mail, such as 'Yours, '} 96 | 97 | \item{mail_date}{character. The date appearing in the mail} 98 | 99 | \item{mail_style}{character. The mail style for mail template. Available styles are (run \code{mail_style()} for hints): 100 | \itemize{ 101 | \item 'casual' (default), 102 | \item 'classic', 103 | \item 'oldstyle', and 104 | \item 'banking' 105 | }} 106 | 107 | \item{mail_theme}{character. The mail theme for mail template. Available themes are (run \code{mail_theme()} for hints): 108 | \itemize{ 109 | \item 'blue' (default), 110 | \item 'orange', 111 | \item 'green', 112 | \item 'red', 113 | \item 'purple', 114 | \item 'grey', and 115 | \item 'black' 116 | }} 117 | 118 | \item{mail_font}{character. The font of the body for mail template. Available fonts are (run \code{mail_font()} for hints): 119 | \itemize{ 120 | \item 'sffamily' (default), or 121 | \item 'calligra' 122 | }} 123 | 124 | \item{mail_fontsize}{character. fontsize of the mail for mail template. Available sizes are (run \code{mail_fontsize()} for hints): 125 | \itemize{ 126 | \item '10pt', 127 | \item '11pt', and 128 | \item '12pt' (default) 129 | }} 130 | 131 | \item{mail_bodysize}{character. fontsize of the mail body for mail template. Available sizes are (run \code{mail_bodysize()} for hints): 132 | \itemize{ 133 | \item 'tiny', 134 | \item 'scriptsize', 135 | \item 'footnotesize', 136 | \item 'small', 137 | \item 'normalsize' (default), 138 | \item 'large', 139 | \item 'Large', 140 | \item 'LARGE', 141 | \item 'huge', 142 | \item 'Huge'. 143 | }} 144 | 145 | \item{poster_email}{character. author's email for poster template} 146 | 147 | \item{poster_institute}{character. for poster template} 148 | 149 | \item{poster_longinstitute}{character. for poster template} 150 | 151 | \item{poster_web}{character. for poster template} 152 | 153 | \item{poster_logo}{character. The path of the logo image. for poster template} 154 | 155 | \item{poster_backimg}{character. The path of the background image. for poster template} 156 | 157 | \item{poster_bibliofiles}{character. The path of the bib file for poster template} 158 | 159 | \item{poster_theme}{character. theme for poster template. available themes are 160 | \itemize{ 161 | \item 'eco' (default), 162 | \item 'ocean', 163 | \item 'rose', 164 | \item 'night', 165 | \item 'ice'. 166 | }} 167 | } 168 | \value{ 169 | demo files to build with bookdown 170 | } 171 | \description{ 172 | Technically, \code{bookdownplus} is a collection and selector of R bookdown templates. \code{bookdownplus} helps you write academic journal articles, guitar books, chemical equations, mails, calendars, and diaries. R \code{bookdownplus} extends the features of \code{bookdown}, and simplifies the procedure. Users only have to choose a template, clarify the book title and author name, and then focus on writing the text. No need to struggle in YAML and LaTeX. 173 | 174 | Full documentation of \code{bookdownplus} can be found in the book \href{https://bookdown.org/baydap/bookdownplus}{R bookdownplus Textbook}. Here is a quick-start procedure. 175 | \itemize{ 176 | \item Before starting, you have to install \code{bookdown} package, and other software and packages (i.e. 'Pandoc', 'LaTeX', \code{rmarkdown}, \code{rticle}, \code{knitr}, etc.) which \code{bookdown} depends on. See the \href{https://bookdown.org/yihui/bookdown/}{official manual of bookdown} for details. Additionally, if you want to produce a poster, phython must be installed before using, and the path of phython might have to be added to the environmental variables for Windows users. 177 | \item Run \code{bookdownplus()} and specify the template with \code{template} argument, You will get some files (e.g. \code{index.Rmd}, \code{body.Rmd}, \code{bookdownplus.Rproj}) and folders in your working directory. Although there are many other arguments for \code{bookdownplus()}, you can simply ignore them if you use \code{bookdownplus} package for the first time. 178 | \item Open \code{bookdownplus.Rproj} with RStudio. Now press \code{ctrl+shift+b} to build it. Your will get a book file named \code{*.pdf} in \code{_book/} folder. 179 | \item Write your own text in \code{index.Rmd} and \code{body.Rmd}, and build your own lovely book. 180 | } 181 | } 182 | \examples{ 183 | bookdownplus(render = FALSE) 184 | bookdownplus(template = "article", render = FALSE) 185 | } 186 | -------------------------------------------------------------------------------- /inst/bib/bib.bib: -------------------------------------------------------------------------------- 1 | @Manual{R-rgl, 2 | title = {rgl: 3D Visualization Using OpenGL}, 3 | author = {Daniel Adler and Duncan Murdoch and {others}}, 4 | year = {2017}, 5 | note = {R package version 0.97.0}, 6 | url = {https://CRAN.R-project.org/package=rgl}, 7 | } 8 | @Manual{R-rmarkdown, 9 | title = {rmarkdown: Dynamic Documents for R}, 10 | author = {JJ Allaire and Joe Cheng and Yihui Xie and Jonathan McPherson and Winston Chang and Jeff Allen and Hadley Wickham and Aron Atkins and Rob Hyndman}, 11 | year = {2016}, 12 | note = {R package version 1.3}, 13 | url = {https://CRAN.R-project.org/package=rmarkdown}, 14 | } 15 | @Manual{R-rgdal, 16 | title = {rgdal: Bindings for the Geospatial Data Abstraction Library}, 17 | author = {Roger Bivand and Tim Keitt and Barry Rowlingson}, 18 | year = {2016}, 19 | note = {R package version 1.2-5}, 20 | url = {https://CRAN.R-project.org/package=rgdal}, 21 | } 22 | @Manual{R-maptools, 23 | title = {maptools: Tools for Reading and Handling Spatial Objects}, 24 | author = {Roger Bivand and Nicholas Lewin-Koh}, 25 | year = {2017}, 26 | note = {R package version 0.9-1}, 27 | url = {https://CRAN.R-project.org/package=maptools}, 28 | } 29 | @Article{R-openair, 30 | title = {openair --- An R package for air quality data analysis}, 31 | author = {David C. Carslaw and Karl Ropkins}, 32 | journal = {Environmental Modelling \& Software}, 33 | volume = {27--28}, 34 | number = {0}, 35 | pages = {52--61}, 36 | year = {2012}, 37 | issn = {1364-8152}, 38 | doi = {10.1016/j.envsoft.2011.09.008}, 39 | } 40 | @Manual{R-xlsx, 41 | title = {xlsx: Read, write, format Excel 2007 and Excel 97/2000/XP/2003 files}, 42 | author = {Adrian A. Dragulescu}, 43 | year = {2014}, 44 | note = {R package version 0.5.7}, 45 | url = {https://CRAN.R-project.org/package=xlsx}, 46 | } 47 | @Manual{R-ReporteRs, 48 | title = {ReporteRs: Microsoft Word and PowerPoint Documents Generation}, 49 | author = {David Gohel}, 50 | year = {2017}, 51 | note = {R package version 0.8.8}, 52 | url = {https://CRAN.R-project.org/package=ReporteRs}, 53 | } 54 | @Article{R-plotrix, 55 | year = {2006}, 56 | title = {Plotrix: a package in the red light district of R}, 57 | journal = {R-News}, 58 | volume = {6}, 59 | number = {4}, 60 | pages = {8-12}, 61 | author = {Lemon J}, 62 | } 63 | @Manual{R-leafletCN, 64 | title = {leafletCN: An R Gallery for China and Other Geojson Choropleth Map in 65 | Leaflet}, 66 | author = {Dawei Lang}, 67 | year = {2017}, 68 | note = {R package version 0.2.1}, 69 | url = {https://CRAN.R-project.org/package=leafletCN}, 70 | } 71 | @Article{R-simecol, 72 | title = {simecol: An Object-Oriented Framework for Ecological Modeling in R}, 73 | author = {Thomas Petzoldt and Karsten Rinke}, 74 | journal = {Journal of Statistical Software}, 75 | volume = {22}, 76 | number = {9}, 77 | pages = {1--31}, 78 | year = {2007}, 79 | coden = {JSSOBK}, 80 | issn = {1548-7660}, 81 | url = {http://www.jstatsoft.org/v22/i09}, 82 | keywords = {ecological modeling, individual-based model, 83 | object-oriented programming (OOP), 84 | code-sharing, R.}, 85 | } 86 | @Manual{R-base, 87 | title = {R: A Language and Environment for Statistical Computing}, 88 | author = {{R Core Team}}, 89 | organization = {R Foundation for Statistical Computing}, 90 | address = {Vienna, Austria}, 91 | year = {2016}, 92 | url = {https://www.R-project.org/}, 93 | } 94 | @Book{R-lattice, 95 | title = {Lattice: Multivariate Data Visualization with R}, 96 | author = {Deepayan Sarkar}, 97 | publisher = {Springer}, 98 | address = {New York}, 99 | year = {2008}, 100 | note = {ISBN 978-0-387-75968-5}, 101 | url = {http://lmdvr.r-forge.r-project.org}, 102 | } 103 | @Manual{R-timeDate, 104 | title = {timeDate: Rmetrics - Chronological and Calendar Objects}, 105 | author = {Rmetrics Core Team and Diethelm Wuertz and Tobias Setz and Yohan Chalabi and Martin Maechler and Joe W. Byers}, 106 | year = {2015}, 107 | note = {R package version 3012.100}, 108 | url = {https://CRAN.R-project.org/package=timeDate}, 109 | } 110 | @Book{R-ggplot2, 111 | author = {Hadley Wickham}, 112 | title = {ggplot2: Elegant Graphics for Data Analysis}, 113 | publisher = {Springer-Verlag New York}, 114 | year = {2009}, 115 | isbn = {978-0-387-98140-6}, 116 | url = {http://ggplot2.org}, 117 | } 118 | @Manual{R-stringr, 119 | title = {stringr: Simple, Consistent Wrappers for Common String Operations}, 120 | author = {Hadley Wickham}, 121 | year = {2017}, 122 | note = {R package version 1.2.0}, 123 | url = {https://CRAN.R-project.org/package=stringr}, 124 | } 125 | 126 | @Book{xie2014, 127 | title = {knitr: A Comprehensive Tool for Reproducible Research in {R}}, 128 | publisher = {Chapman and Hall/CRC}, 129 | year = {2014}, 130 | author = {Yihui Xie}, 131 | editor = {Victoria Stodden and Friedrich Leisch and Roger D. Peng}, 132 | note = {ISBN 978-1466561595}, 133 | booktitle = {Implementing Reproducible Computational Research}, 134 | url = {http://www.crcpress.com/product/isbn/9781466561595} 135 | }@Article{R-animation1, 136 | title = {{animation}: An {R} Package for Creating Animations and Demonstrating Statistical Methods}, 137 | author = {Yihui Xie}, 138 | journal = {Journal of Statistical Software}, 139 | year = {2013}, 140 | volume = {53}, 141 | number = {1}, 142 | pages = {1--27}, 143 | url = {http://www.jstatsoft.org/v53/i01/}, 144 | } 145 | 146 | @Book{xie2015, 147 | title = {Dynamic Documents with {R} and knitr}, 148 | publisher = {Chapman and Hall/CRC}, 149 | year = {2015}, 150 | author = {Yihui Xie}, 151 | address = {Boca Raton, Florida}, 152 | edition = {2nd}, 153 | note = {ISBN 978-1498716963}, 154 | owner = {Peng Zhao}, 155 | timestamp = {2017.06.22}, 156 | url = {http://yihui.name/knitr/} 157 | } 158 | 159 | @Book{R-bookdown, 160 | title = {bookdown: Authoring Books and Technical Documents with {R} Markdown}, 161 | publisher = {Chapman and Hall/CRC}, 162 | year = {2016}, 163 | author = {Yihui Xie}, 164 | address = {Boca Raton, Florida}, 165 | note = {ISBN 978-1138700109}, 166 | url = {https://github.com/rstudio/bookdown} 167 | } 168 | @Manual{R-bookdown1, 169 | title = {bookdown: Authoring Books and Technical Documents with R Markdown}, 170 | author = {Yihui Xie}, 171 | year = {2016}, 172 | note = {R package version 0.3.10}, 173 | url = {https://github.com/rstudio/bookdown}, 174 | } 175 | @Manual{R-knitr1, 176 | title = {knitr: A General-Purpose Package for Dynamic Report Generation in R}, 177 | author = {Yihui Xie}, 178 | year = {2016}, 179 | note = {R package version 1.15.1}, 180 | url = {http://yihui.name/knitr/}, 181 | } 182 | @Manual{R-blogdown, 183 | title = {blogdown: Create Blogs and Websites with R Markdown}, 184 | author = {Yihui Xie}, 185 | year = {2017}, 186 | note = {R package version 0.0.24}, 187 | url = {https://github.com/rstudio/blogdown}, 188 | } 189 | 190 | @Manual{R-animation2, 191 | title = {animation: A Gallery of Animations in Statistics and Utilities to Create 192 | Animations}, 193 | author = {Yihui Xie and Christian Mueller and Lijia Yu and Weicheng Zhu}, 194 | year = {2015}, 195 | note = {R package version 2.4}, 196 | url = {http://yihui.name/animation}, 197 | } 198 | @Manual{R-fun, 199 | title = {fun: Use R for Fun}, 200 | author = {Yihui Xie and Taiyun Wei and Yixuan Qiu}, 201 | year = {2011}, 202 | note = {R package version 0.1-0}, 203 | url = {https://CRAN.R-project.org/package=fun}, 204 | } 205 | @Manual{R-fortunes, 206 | title = {fortunes: R Fortunes}, 207 | author = {Achim Zeileis and the R community. Contributions (fortunes and/or code) by Torsten Hothorn and Peter Dalgaard and Uwe Ligges and Kevin Wright and Martin Maechler and Kjetil Brinchmann Halvorsen and Kurt Hornik and Duncan Murdoch and Andy Bunn and Ray Brownrigg and Roger Bivand and Spencer Graves and Jim Lemon and Christian Kleiber and David L. Reiner and Berton Gunter and Roger Koenker and Charles Berry and Marc Schwartz and Michael Dewey and Ben Bolker and Peter Dunn and Sarah Goslee and Simon Blomberg and Bill Venables and Roland Rau and Thomas Petzoldt and Rolf Turner and Mark Leeds and Emmanuel Charpentier and Chris Evans and Paolo Sonego and Peter Ehlers and Detlef Steuer and Tal Galili and Greg Snow and Brian D. Ripley and Michael Sumner and David Winsemius and Liviu Andronic and Brian Diggs and Matthieu Stigler and Michael Friendly and Dirk Eddelbuettel and Richard M. Heiberger and Patrick Burns and Dieter Menne and Andrie {de Vries} and Barry Rowlingson and Renaud Lancelot and R. Michael Weylandt and Jon Olav Skoien and Francois Morneau and Antony Unwin and Joshua Wiley and Terry Therneau and Bryan Hanson and Henrik Singmann and Eduard Szoecs and Gregor Passolt and John C. Nash.}, 208 | year = {2016}, 209 | note = {R package version 1.5-4}, 210 | url = {https://CRAN.R-project.org/package=fortunes}, 211 | } 212 | 213 | @Manual{R-bookdownplus, 214 | title = {bookdownplus: Generate Varied Books and Documents with R 'bookdown' Package}, 215 | author = {Peng Zhao}, 216 | year = {2017}, 217 | note = {R package version 1.0.2}, 218 | owner = {Peng Zhao}, 219 | timestamp = {2017.06.22}, 220 | url = {https://CRAN.R-project.org/package=bookdownplus} 221 | } 222 | 223 | @Manual{R-mindr, 224 | title = {mindr: Convert Files Between Markdown or Rmarkdown Files and Mindmaps}, 225 | author = {Peng Zhao}, 226 | year = {2017}, 227 | note = {R package version 1.0.4}, 228 | owner = {Peng Zhao}, 229 | timestamp = {2017.06.22}, 230 | url = {https://github.com/pzhaonet/mindr} 231 | } 232 | 233 | @Manual{R-pinyin, 234 | title = {pinyin: Convert Chinese Characters into Pinyin}, 235 | author = {Peng Zhao}, 236 | year = {2017}, 237 | note = {R package version 1.0.2}, 238 | owner = {Peng Zhao}, 239 | timestamp = {2017.06.22}, 240 | url = {https://github.com/pzhaonet/pinyin} 241 | } 242 | 243 | @Manual{R-postr, 244 | title = {postr: Generage posters with r markdown}, 245 | author = {Peng Zhao}, 246 | year = {2017}, 247 | note = {R package version 0.0.0}, 248 | owner = {Peng Zhao}, 249 | timestamp = {2017.06.22}, 250 | url = {https://github.com/pzhaonet/postr} 251 | } 252 | -------------------------------------------------------------------------------- /inst2/style/expl3.sty: -------------------------------------------------------------------------------- 1 | %% 2 | %% This is file `expl3.sty', 3 | %% generated with the docstrip utility. 4 | %% 5 | %% The original source files were: 6 | %% 7 | %% expl3.dtx (with options: `package,loader') 8 | %% 9 | %% Copyright (C) 1990-2017 The LaTeX3 Project 10 | %% 11 | %% It may be distributed and/or modified under the conditions of 12 | %% the LaTeX Project Public License (LPPL), either version 1.3c of 13 | %% this license or (at your option) any later version. The latest 14 | %% version of this license is in the file: 15 | %% 16 | %% http://www.latex-project.org/lppl.txt 17 | %% 18 | %% This file is part of the "l3kernel bundle" (The Work in LPPL) 19 | %% and all files in that bundle must be distributed together. 20 | %% 21 | %% File: expl3.dtx Copyright (C) 1990-2017 The LaTeX3 Project 22 | \def\ExplFileDate{2017/04/01}% 23 | \let\ExplLoaderFileDate\ExplFileDate 24 | \ProvidesPackage{expl3} 25 | [% 26 | \ExplFileDate\space 27 | L3 programming layer (loader) 28 | ]% 29 | \newcommand\expl@create@bool@option[2]% 30 | {% 31 | \DeclareOption{#1}{\chardef #2=1 }% 32 | \DeclareOption{#1=true}{\chardef #2=1 }% 33 | \DeclareOption{#1=false}{\chardef #2=0 }% 34 | \newcommand*#2{}% 35 | \chardef #2=0 % 36 | } 37 | \expl@create@bool@option{check-declarations}\l@expl@check@declarations@bool 38 | \expl@create@bool@option{log-functions}\l@expl@log@functions@bool 39 | \let\expl@create@bool@option\@undefined 40 | \newcommand*\l@expl@options@clist{} 41 | \DeclareOption* 42 | {% 43 | \ifx\l@expl@options@clist\@empty 44 | \let\l@expl@options@clist\CurrentOption 45 | \else 46 | \expandafter\expandafter\expandafter\def 47 | \expandafter\expandafter\expandafter\l@expl@options@clist 48 | \expandafter\expandafter\expandafter 49 | {\expandafter\l@expl@options@clist\expandafter,\CurrentOption} 50 | \fi 51 | } 52 | \ProcessOptions\relax 53 | \protected\def\ProvidesExplPackage#1#2#3#4% 54 | {% 55 | \ProvidesPackage{#1}[#2 \ifx\relax#3\relax\else v#3\space\fi #4]% 56 | \ExplSyntaxOn 57 | } 58 | \protected\def\ProvidesExplClass#1#2#3#4% 59 | {% 60 | \ProvidesClass{#1}[#2 \ifx\relax#3\relax\else v#3\space\fi #4]% 61 | \ExplSyntaxOn 62 | } 63 | \protected\def\ProvidesExplFile#1#2#3#4% 64 | {% 65 | \ProvidesFile{#1}[#2 \ifx\relax#3\relax\else v#3\space\fi #4]% 66 | \ExplSyntaxOn 67 | } 68 | \input{expl3-code.tex} 69 | \begingroup\expandafter\expandafter\expandafter\endgroup 70 | \expandafter\ifx\csname tex\string _let:D\endcsname\relax 71 | \expandafter\endinput 72 | \fi 73 | \AtBeginDocument 74 | { 75 | \cs_if_exist:NF \color 76 | { \DeclareRobustCommand \color [2] [ ] { } } 77 | } 78 | \__msg_kernel_new:nnnn { expl } { wrong-driver } 79 | { Driver~request~inconsistent~with~engine:~using~'#2'~driver. } 80 | { 81 | You~have~requested~driver~'#1',~but~this~is~not~suitable~for~use~with~the~ 82 | active~engine.~LaTeX3~will~use~the~'#2'~driver~instead. 83 | } 84 | \tl_new:N \l__expl_driver_tl 85 | \keys_define:nn { expl } 86 | { 87 | driver .choice:, 88 | driver / auto .code:n = 89 | { 90 | \tl_set:Nx \l__expl_driver_tl 91 | { 92 | \sys_if_engine_xetex:TF 93 | { xdvipdfmx } 94 | { 95 | \sys_if_output_pdf:TF 96 | { pdfmode } 97 | { 98 | \bool_if:nTF 99 | { 100 | \sys_if_engine_pdftex_p: || 101 | \sys_if_engine_luatex_p: 102 | } 103 | { dvips } 104 | { dvipdfmx } 105 | } 106 | } 107 | } 108 | }, 109 | driver / dvipdfmx .code:n = 110 | { 111 | \tl_set:Nn \l__expl_driver_tl { dvipdfmx } 112 | \sys_if_engine_xetex:TF 113 | { 114 | \__msg_kernel_error:nnnn { expl } { wrong-driver } 115 | { dvipdfmx } { xdvipdfmx } 116 | \tl_set:Nn \l__expl_driver_tl { xdvipdfmx } 117 | } 118 | { 119 | \sys_if_output_pdf:T 120 | { 121 | \__msg_kernel_error:nnnn { expl } { wrong-driver } 122 | { dvipdfmx } { pdfmode } 123 | \tl_set:Nn \l__expl_driver_tl { pdfmode } 124 | } 125 | } 126 | }, 127 | driver / dvips .code:n = 128 | { 129 | \tl_set:Nn \l__expl_driver_tl { dvips } 130 | \sys_if_engine_xetex:TF 131 | { 132 | \__msg_kernel_error:nnnn { expl } { wrong-driver } 133 | { dvips } { xdvipdfmx } 134 | \tl_set:Nn \l__expl_driver_tl { xdvipdfmx } 135 | } 136 | { 137 | \sys_if_output_pdf:T 138 | { 139 | \__msg_kernel_error:nnnn { expl } { wrong-driver } 140 | { dvips } { pdfmode } 141 | \tl_set:Nn \l__expl_driver_tl { pdfmode } 142 | } 143 | } 144 | }, 145 | driver / dvisvgm .code:n = 146 | { 147 | \tl_set:Nn \l__expl_driver_tl { dvisvgm } 148 | \sys_if_engine_xetex:TF 149 | { 150 | \__msg_kernel_error:nnnn { expl } { wrong-driver } 151 | { dvips } { xdvipdfmx } 152 | \tl_set:Nn \l__expl_driver_tl { xdvipdfmx } 153 | } 154 | { 155 | \sys_if_output_pdf:T 156 | { 157 | \__msg_kernel_error:nnnn { expl } { wrong-driver } 158 | { dvips } { pdfmode } 159 | \tl_set:Nn \l__expl_driver_tl { pdfmode } 160 | } 161 | } 162 | }, 163 | driver / latex2e .code:n = 164 | { \tl_set:Nn \l__expl_driver_tl { latex2e } }, 165 | driver / pdfmode .code:n = 166 | { 167 | \tl_set:Nn \l__expl_driver_tl { pdfmode } 168 | \sys_if_engine_xetex:TF 169 | { 170 | \__msg_kernel_error:nnnn { expl } { wrong-driver } 171 | { pdfmode } { xdvipdfmx } 172 | \tl_set:Nn \l__expl_driver_tl { xdvipdfmx } 173 | } 174 | { 175 | \sys_if_output_pdf:F 176 | { 177 | \__msg_kernel_error:nnnn { expl } { wrong-driver } 178 | { pdfmode } { dvips } 179 | \tl_set:Nn \l__expl_driver_tl { dvips } 180 | } 181 | } 182 | }, 183 | driver / xdvipdfmx .code:n = 184 | { 185 | \tl_set:Nn \l__expl_driver_tl { xdvipdfmx } 186 | \sys_if_engine_xetex:F 187 | { 188 | \sys_if_output_pdf:TF 189 | { 190 | \__msg_kernel_error:nnnn { expl } { wrong-driver } 191 | { xdvipdfmx } { pdfmode } 192 | \tl_set:Nn \l__expl_driver_tl { pdfmode } 193 | } 194 | { 195 | \__msg_kernel_error:nnnn { expl } { wrong-driver } 196 | { xdvipdfmx } { dvips } 197 | \tl_set:Nn \l__expl_driver_tl { dvips } 198 | } 199 | } 200 | }, 201 | driver .initial:n = { auto } , 202 | native-drivers .choice:, 203 | native-drivers .default:n = { true }, 204 | native-drivers / false .meta:n = { driver = latex2e }, 205 | native-drivers / true .meta:n = { driver = auto } 206 | } 207 | \keys_define:nn { expl } 208 | { 209 | check-declarations .bool_set:N = \l@expl@check@declarations@bool, 210 | log-functions .bool_set:N = \l@expl@log@functions@bool 211 | } 212 | \keys_set:nV { expl } \l@expl@options@clist 213 | \str_if_eq:VnTF \l__expl_driver_tl { latex2e } 214 | { 215 | \tl_gput_left:Nn \@begindocumenthook { \RequirePackage { graphics } } 216 | \__msg_kernel_new:nnnn { box } { clipping-not-available } 217 | { Box~clipping~not~available. } 218 | { 219 | The~\box_clip:N~function~is~only~available~when~loading~expl3~ 220 | with~the~"native-drivers"~option. 221 | } 222 | \cs_set_protected:Npn \box_clip:N #1 223 | { 224 | \hbox_set:Nn #1 { \box_use:N #1 } 225 | \__msg_kernel_error:nn { box } { clipping-not-available } 226 | } 227 | \cs_set_protected:Npn \box_rotate:Nn #1#2 228 | { \hbox_set:Nn #1 { \rotatebox {#2} { \box_use:N #1 } } } 229 | \cs_set_protected:Npn \box_resize:Nnn #1#2#3 230 | { 231 | \hbox_set:Nn #1 232 | { 233 | \resizebox * 234 | { \__dim_eval:w #2 \__dim_eval_end: } 235 | { \__dim_eval:w #3 \__dim_eval_end: } 236 | { \box_use:N #1 } 237 | } 238 | } 239 | \cs_set_protected:Npn \box_resize_to_ht_plus_dp:Nn #1#2 240 | { 241 | \hbox_set:Nn #1 242 | { 243 | \resizebox * { ! } { \__dim_eval:w #2 \__dim_eval_end: } 244 | { \box_use:N #1 } 245 | } 246 | } 247 | \cs_set_protected:Npn \box_resize_to_wd:Nn #1#2 248 | { 249 | \hbox_set:Nn #1 250 | { 251 | \resizebox * { \__dim_eval:w #2 \__dim_eval_end: } { ! } 252 | { \box_use:N #1 } 253 | } 254 | } 255 | \cs_set_protected:Npn \box_scale:Nnn #1#2#3 256 | { 257 | \hbox_set:Nn #1 258 | { 259 | \exp_last_unbraced:Nx \scalebox 260 | { { \fp_eval:n {#2} } [ \fp_eval:n {#3} ] } 261 | { \box_use:N #1 } 262 | } 263 | } 264 | } 265 | { 266 | \group_begin: 267 | \cs_set_protected:Npn \ProvidesExplFile 268 | { 269 | \char_set_catcode_space:n { `\ } 270 | \ProvidesExplFileAux 271 | } 272 | \cs_set_protected:Npn \ProvidesExplFileAux #1#2#3#4 273 | { 274 | \group_end: 275 | \ProvidesFile {#1} [ #2~v#3~#4 ] 276 | } 277 | \tl_const:Nn \c__expl_def_ext_tl { def } 278 | \@onefilewithoptions { l3 \l__expl_driver_tl } [ ] [ ] \c__expl_def_ext_tl 279 | } 280 | \tl_put_left:Nn \@pushfilename 281 | { 282 | \tl_put_left:Nx \l__expl_status_stack_tl 283 | { 284 | \bool_if:NTF \l__kernel_expl_bool 285 | { 1 } 286 | { 0 } 287 | } 288 | \ExplSyntaxOff 289 | } 290 | \tl_put_right:Nn \@popfilename 291 | { 292 | \tl_if_empty:NTF \l__expl_status_stack_tl 293 | { \ExplSyntaxOff } 294 | { \exp_after:wN \__expl_status_pop:w \l__expl_status_stack_tl \q_stop } 295 | } 296 | \cs_new_protected:Npn \__expl_status_pop:w #1#2 \q_stop 297 | { 298 | \tl_set:Nn \l__expl_status_stack_tl {#2} 299 | \int_if_odd:nTF {#1} 300 | { \ExplSyntaxOn } 301 | { \ExplSyntaxOff } 302 | } 303 | \tl_new:N \l__expl_status_stack_tl 304 | \tl_set:Nn \l__expl_status_stack_tl { 0 } 305 | %% 306 | %% 307 | %% End of file `expl3.sty'. 308 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | bookdownplus: an R package for writing assorted books and documents, such as academic articles, mails, guitar chords, chemical melecular formulae, with R bookdown 2 | ================================================================================================================================================================== 3 | 4 | ![CRAN downloads](http://cranlogs.r-pkg.org/badges/grand-total/bookdownplus) 5 | 6 | Introduction 7 | ============ 8 | 9 | The R package [`bookdownplus`](https://cran.r-project.org/web/packages/bookdownplus) (Zhao 2017a) is an extension of `bookdown` (Xie 2016). It is a collection of multiple templates on the basis of LaTeX, which are tailored so that I can work happily under the umbrella of `bookdown`. `bookdownplus` helps you write academic journal articles, guitar books, chemical equations, mails, calendars, and diaries. 10 | 11 | Features 12 | ======== 13 | 14 | `bookdown` is not easy for beginners. Try reading the official manual of [‘bookdown’](https://bookdown.org/yihui/bookdown/). If you are able to build your own book in one hour, I am sure you are a genius and please send me a postcard with your signature. An R beginner might be confused or depressed in struggling in the flood of LaTeX, YAML, Markdown, Pandoc, etc. It would be a pity if users stop their steps at the door and give up the courage of entering the wonderful world of `bookdown`. 15 | 16 | `bookdownplus` is the easiest shortcut to the world of `bookdown`. With **just one single command** users can get a demo book (or multiple demo books) in .pdf or .doc, or even more formats (see the quick start section). `bookdownplus` extends the features of `bookdown`, and simplifies the procedure. Users only have to choose a template, clarify the book title and author name, and then focus on writing the text. No need to struggle in YAML and LaTeX. 17 | 18 | With `bookdownplus` users can 19 | 20 | - write a mail in an elegant layout, 21 | - write a laboratory journal, or a personal diary, 22 | - draw a monthly or weekly or conference calendar, 23 | - and, of course, write academic articles in your favourite way, 24 | - with chemical molecular formulae and equations, 25 | - even in Chinese, 26 | - record guitar chords, 27 | - and more wonders are coming soon. 28 | 29 | Full documentation can be found in the book [R bookdownplus Textbook](https://bookdown.org/baydap/bookdownplus). The webpage looks as elegant as other books, while the [pdf file](https://bookdown.org/baydap/bookdownplus/bookdownplus.pdf) might give you a little surprise. 30 | 31 | Quick start 32 | =========== 33 | 34 | Preparation 35 | ----------- 36 | 37 | Before starting, you have to install ‘R’, ‘RStudio’, ‘bookdown’ package, and other software and packages (i.e.’Pandoc’, ‘LaTeX’, ‘rmarkdown’, ‘rticle’, ‘knitr’, etc.) which ‘bookdown’ depends on. See the [official manual of ‘bookdown’](https://bookdown.org/yihui/bookdown/) for details. A brief list is as follows: 38 | 39 | 1. Download [R](https://cran.r-project.org) and install it. 40 | 41 | 2. Download [RStudio](https://www.rstudio.com/products/rstudio/download/) and install it. 42 | 43 | 3. Download LaTeX(e.g. [CTeX](http://www.ctex.org/CTeXDownload) or [TinyTeX](https://yihui.name/tinytex/)) and install it. 44 | 45 | 4. Run RStudio. Type the following codes in the top-left panel to install ‘bookdown’ packages: 46 | 47 | ``` r 48 | install.packages('bookdown') 49 | ``` 50 | 51 | Additionally, if you want to produce a poster, Python must be installed before using, and the path of Python might have to be added to the environmental variables for Windows users. Details can be found in the instruction of [kuleuven-templates](https://github.com/exporl/kuleuven-templates), which is the origin of the ‘poster’ template. 52 | 53 | Installation 54 | ------------ 55 | 56 | ``` r 57 | # the development version from GitHub (recommended) 58 | devtools::install_github("pzhaonet/bookdownplus") 59 | # or the stable version from CRAN 60 | install.package("bookdownplus") 61 | ``` 62 | 63 | Generate a demo book 64 | -------------------- 65 | 66 | Firstly check your working directory (`getwd()`) and make sure that it is empty. `bookdownplus` will generate lots of files. An empty folder as a working directory is highly recommended. If you don’t know how to change your working directory with R command, you can use RStudio to create a new project (File – New Project - New Directory – Empty Project) and work always in this project. 67 | 68 | Run the following codes: 69 | 70 | ``` r 71 | require(bookdownplus) 72 | ``` 73 | 74 | ``` r 75 | bookdownplus() 76 | ``` 77 | 78 | Although there are many arguments for `bookdownplus()`, you can simply ignore them and they will use their default values, if you use ‘bookdownplus’ package for the first time. 79 | 80 | Now a demo file named `*.pdf` in `_book/` folder in your working directory is generated automatically. Open it with any pdf viewer so as to get an impression. 81 | 82 | Write your own book 83 | ------------------- 84 | 85 | You can see some other files (e.g. `index.Rmd`, `body.Rmd`, `bookdownplus.Rproj`) and folders. Write your own texts in `body.Rmd` and revise the author and the book title in `index.Rmd`. You can use RStudio or any other text editor (but please don’t use Microsoft Word, believe it or not). 86 | 87 | After writing some texts, open `bookdownplus.Rproj` with RStudio, and press `ctrl+shift+b` to build your own lovely book. 88 | 89 | More output formats 90 | ------------------- 91 | 92 | By default, the book is built in a .pdf file and an .md file. From ‘bookdownplus v1.0.3’, users can get more output formats, including word, html and epub. From ‘bookdownplus v1.2.0’, uses can see the available output formats by running: 93 | 94 | ``` r 95 | more_output() 96 | ``` 97 | 98 | ## [1] "word_document2" "epub_book" "gitbook" "html_document2" 99 | 100 | You can specify the `more_output` argument in the `bookdownplus()` function: 101 | 102 | ``` r 103 | bookdownplus(more_output = more_output()) 104 | ``` 105 | 106 | Then all the required output files are in `_book/` folder. 107 | 108 | More templates 109 | -------------- 110 | 111 | By default, the book is built from the ‘thesis\_classic’ template. From ‘bookdownplus v1.2.0’, users can see the available templates by running: 112 | 113 | ``` r 114 | template() 115 | ``` 116 | 117 | ## [1] "article" "article_mdpi" "article_zh" 118 | ## [4] "calendar" "cchess" "chemistry" 119 | ## [7] "chemistry_zh" "discussion" "dnd_dev" 120 | ## [10] "docsens" "guitar" "igo" 121 | ## [13] "journal" "mail" "musix" 122 | ## [16] "nonpar" "nte_zh" "poem" 123 | ## [19] "poster" "rbasics" "skak" 124 | ## [22] "thesis_classic" "thesis_mypku_zh" "thesis_pku_zh" 125 | ## [25] "thesis_ubt" "thesis_zju_zh" "yihui_crc" 126 | ## [28] "yihui_demo" "yihui_mini" "yihui_zh" 127 | 128 | A template with a name ended with ’\_zh’ means it support Chinese characters. To list all these Chinese templates, run: 129 | 130 | ``` r 131 | grep('_zh$', template(), value = TRUE) 132 | ``` 133 | 134 | ## [1] "article_zh" "chemistry_zh" "nte_zh" "thesis_mypku_zh" 135 | ## [5] "thesis_pku_zh" "thesis_zju_zh" "yihui_zh" 136 | 137 | You can specify the `template` argument in the `bookdownplus()` function: 138 | 139 | ``` r 140 | bookdownplus(template = template()[1]) 141 | ``` 142 | 143 | Then all the required output files are in `_book/` folder. 144 | 145 | Magic tricks 146 | ------------ 147 | 148 | Now it is time to witness the miracles. With the following magic tricks you will see what bookdownplus can do. 149 | 150 | **Magic I** 151 | 152 | Chinese users can run the following codes, and go and have a coffee break. When you come back, you will get more than 20 demo books generated from available tempaltes, each in .pdf, .doc, .html, and .epub formats, in `_book/`: 153 | 154 | ``` r 155 | bd() 156 | ``` 157 | 158 | Non-Chinese users might encounter some errors because their computers do not support Chinese characters in the demo books. Instead, run the following codes, which exclude the Chinese templates: 159 | 160 | ``` r 161 | bd(x = template()[-c(grep('_zh$', template()), which(template() == 'poster'))]) 162 | ``` 163 | 164 | **Magic II** 165 | 166 | Run the following codes. You will get all the demo files for different fonts, themes and styles from the ‘mail’ template: 167 | 168 | ``` r 169 | bd(x = NA, mail_all = TRUE) 170 | ``` 171 | 172 | Recommendations 173 | --------------- 174 | 175 | I have been developing some other packages, which bring more features into ‘bookdown’, such as: 176 | 177 | - [mindr](https://cran.r-project.org/web/packages/mindr) (Zhao 2017b), which can extract the outline of your book and turn it into a mind map, and 178 | 179 | - [pinyin](https://cran.r-project.org/web/packages/pinyin) (Zhao 2017c), which can automatically generate [‘{\#ID}’](https://bookdown.org/yihui/bookdown/cross-references.html) of the chapter headers even if there are Chinese characters in them. 180 | 181 | Both of them have been released on CRAN and can be installed via `install.packages('mindr')` and `install.packages('pinyin')`. 182 | 183 | Enjoy your bookdowning! 184 | 185 | Create Your Own Templates 186 | ------------------------- 187 | 188 | `bookdownplus` provides around 20 templates (Version 1.2.0) and more will be included in the future. I am not an expert in LaTeX but I have successfully created these templates. It means that creating a LaTeX template does not require much knowledge in LaTeX. If you know the general workflow of LaTeX, and study these ‘bookdownplus’ templates carefully, and read Chapter 4 of the [official manual of ‘bookdown’](https://bookdown.org/yihui/bookdown/), you will get the idea of how to create your own templates. 189 | 190 | Here is some hints from my experience on creating a new template from am existing LaTeX template: 191 | 192 | - Find a nice LaTeX template. There are many websites that provide free LaTeX templates. You can download one you like most. Those with good documentations and comments are highly recommended. 193 | 194 | - Compile the LaTeX template file to make sure that it can work fine and produce the right pdf file. You could either use command lines or use some software like TexStudio to compile it. You could send to me this template with its full documentation and your pdf file, if you do not want to continue. I would try tailoring it into ‘bookdownplus’ but it is not guaranteed. It depends on my time and mood. Thus I recommend you to be brave and continue the next steps. 195 | - Cut the template into ‘template\_yours.tex’ and ‘index.Rmd’ in the following way: 196 | - The main body of the LaTeX are the part between `\begin{document}` and `\end{document}`. Replace the main body with `$body$`, which will be filled with ‘body.Rmd’. You can use any ’body\*.Rmd’ created by ‘bookdownplus’. 197 | - Use any ‘index.Rmd’ created by ‘bookdownplus’ and modify the name of the LaTex template in ‘index.Rmd’. 198 | - If the LaTeX template is simple enough, now you may build this template book with ‘bookdown’. 199 | 200 | - Usually it won’t work. A good-looking LaTeX template is mostly complicated, especially those in Chinese. Probably you have to modify the preamble, pick out some parts and save them and specify them in ‘index.Rmd’. See the official [manual of ‘bookdown’](https://bookdown.org/yihui/bookdown/yaml-options.html). 201 | 202 | - If you can successfully build your book with your new template, congratulations. It would be appreciated if you could send me your ‘index.Rmd’, ‘body.Rmd’, ‘template\_yours.tex’ and other related files. I will add them into ‘bookdownplus’ templates and add your name into the contributor list. 203 | 204 | Let’s build a ‘bookdownplus’ template library! 205 | 206 | Showcase 207 | -------- 208 | 209 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_article.jpg) 210 | 211 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_article_mdpi.jpg) 212 | 213 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_article_zh.jpg) 214 | 215 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_calendar.jpg) 216 | 217 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_chemistry.jpg) 218 | 219 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_dnd_dev.jpg) ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_discussion.jpg) 220 | 221 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_guitar.jpg) 222 | 223 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_journal.jpg) 224 | 225 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_mail.jpg) 226 | 227 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_nonpar.jpg) 228 | 229 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_nte_zh.jpg) 230 | 231 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_poem.jpg) 232 | 233 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_thesis_classic.jpg) 234 | 235 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_thesis_mypku.jpg) 236 | 237 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_thesis_pku.jpg) 238 | 239 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_thesis_ubt.jpg) 240 | 241 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_thesis_zju.jpg) 242 | 243 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_yihui_crc.jpg) 244 | 245 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_yihui_demo.jpg) 246 | 247 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_yihui_mini.jpg) 248 | 249 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_yihui_zh.jpg) 250 | 251 | ![](https://raw.githubusercontent.com/pzhaonet/bookdownplus/master/inst2/showcase/bookdownplus_poster.jpg) 252 | 253 | Updates 254 | ------- 255 | 256 | - 2018-06-10. **v1.4.6**. More templates: 257 | - cchess 258 | - dnd_dev 259 | - docsens 260 | - igo 261 | - musix 262 | - nonpar 263 | - rbasics 264 | - thesis_pku_zh 265 | - 2018-06-03. **v1.4.5**. 'skak' template, for writing a chess diagram. 266 | - 2018-05-10. **v1.4.4**. One more template, 'yihui\_crc', for writing a book of Chapman & Hall. 267 | - 2018-02-05. **v1.4.3**. Bugs fixed. 268 | - `pandoc_args` changed from `--chapters` into `--top-level-division=chapter` 269 | - 2017-11-24. **v1.4.0**. Structure changed. Minor bugs fixed. 270 | - Template files organized much better. Flexible of adding new templates. 271 | - 2017-10-10. **v1.3.2**. Minor bugs fixed, one more argument, package size reduced 272 | - Argument `rproj` added to `bookdownplus()` function so that users can avoid creating an .Rproj file automatically. 273 | - 'fonts' folder removed so that the package size is smaller than 5 MB. The 'fonts' folder can be downloaded automatically from github repo if necessary. 274 | - 2017-09-22. **v1.3.1.** Some minor bugs fixed. Markdown file produced besides pdf as default. 275 | - 2017-07-19. **v1.3.0.** Updated on CRAN. See the [release note](https://github.com/pzhaonet/bookdownplus/releases/tag/v1.3). 276 | - 2017-06-30. **v1.2.2.** Template names. Poster themes. A bug fixed. 277 | - A template name ended with `_zh` means this template supports Chinese characters. 278 | - Poster themes: 279 | - More themes added: `ice` and `ocean`. 280 | - New function `poster_theme()` which lists available poster themes. 281 | - ​A bug in thesis_classic fixed. 282 | - 2017-06-27. **v1.2.1.** Argument `output_name` added. Then 283 | - 2017-06-26. **v1.2.0.** Easier, faster, and more functions. 284 | - Easier and faster: 285 | - `bookdownplus()` can render the demo files automatically. You don't have to open a .Rproj file to generate the template files any more! 286 | - If you don't like the automatic building, you can use the argument `render = FALSE` in `bookdownplus()` to switch it off. 287 | - New functions: 288 | - `more_output()`: display available output formats besides pdf\_book 289 | - `template()`: display available templates 290 | - `mail_bodysize()`: display available fontsize for mail body 291 | - `mail_font()`: display available fonts for mail body 292 | - `mail_fontsize()`: display available fontsize for mail template 293 | - `mail_style()`: display available styles for mail template 294 | - `mail_theme()`: display available themes for mail template 295 | - 2017-06-24. **v1.1.0.** More templates! See `help(bookdownplus)` 296 | - Templates: 297 | - 'discussion', for academic article in discussion format. 298 | - 'thesis\_mypku', in Chinese, the master thesis template I used more than ten years ago. 299 | - 'nte\_zh', in Chinese, for novels. 300 | - 'mail' template updates: 301 | - more styles, 302 | - more themes. 303 | - 2017-06-23. **v1.0.3.** 304 | - Fixed a bug of thesis\_classic. 305 | - Switched off warnings when creating folders. 306 | - Options to export epub, html, and word documents. 307 | - 2017-06-21. **v1.0.2.** [Released on CRAN](https://cran.r-project.org/web/packages/bookdownplus/index.html)! 308 | - 2017-06-21. **v1.0.2.** Resubmitted to CRAN! 309 | - 2017-06-21. **v1.0.1.** Submitted to CRAN! 310 | - 2017-06-14. **v0.0.1.** A bug fixed. 311 | - 2017-05-15. **v0.0.0.** A very preliminary version. 312 | 313 | License 314 | ======= 315 | 316 | Copyright 2018 [Peng Zhao](http://pzhao.org). 317 | 318 | Released under the [MIT](https://github.com/pzhaonet/bookdown-plus/blob/master/LICENSE.md) license. 319 | 320 | References 321 | ========== 322 | 323 | Xie, Yihui. 2016. *Bookdown: Authoring Books and Technical Documents with R Markdown*. . 324 | 325 | Zhao, Peng. 2017a. *Bookdownplus: Generate Varied Types of Books and Documents with R ’Bookdown’ Package*. . 326 | 327 | ———. 2017b. *Mindr: Convert Files Between Markdown or Rmarkdown Files and Mindmaps*. . 328 | 329 | ———. 2017c. *Pinyin: Convert Chinese Characters into Pinyin*. . 330 | -------------------------------------------------------------------------------- /R/fun.R: -------------------------------------------------------------------------------- 1 | #' Available templates 2 | #' 3 | #' @param dataframe logical. FALSE by default. whether return a vector or a data frame. 4 | #' 5 | #' @return a vector or a dataframe displaying available templates. 6 | #' @export 7 | #' 8 | #' @examples template() 9 | template <- function(dataframe = FALSE){ 10 | pckpath <- paste0(path.package('bookdownplus'), '/zip') 11 | zipfiles <- list.files(path = pckpath, pattern = '\\.zip$') 12 | temp <- gsub('.zip', '', zipfiles) 13 | if (dataframe) { 14 | txt <- NULL 15 | txtfiles <- paste0(pckpath, '/', temp, '.txt') 16 | for(i in txtfiles) { 17 | if(file.exists(i)) 18 | newtxt <- paste0(readLines(i, encoding = 'UTF-8'), collapse = '') 19 | else { 20 | newtxt <- NA 21 | # file.create(i) 22 | } 23 | txt <- c(txt, newtxt) 24 | } 25 | tempdf <- data.frame(i = 1:length(temp), 26 | template = temp, 27 | descript = txt) 28 | return(tempdf) 29 | } 30 | return(temp) 31 | } 32 | 33 | #' Available output formats besides pdf_book 34 | #' 35 | #' @param dataframe logical. FALSE by default. whether return a vector or a data frame. 36 | #' 37 | #' @return a vector or a dataframe. 38 | #' @export 39 | #' 40 | #' @examples more_output() 41 | more_output <- function(dataframe = FALSE){ 42 | temp <- c('word_document2', 43 | 'epub_book', 44 | 'gitbook', 45 | 'html_document2') 46 | tempdf <- data.frame(i = 1:length(temp), 47 | template = temp) 48 | if (dataframe) return(tempdf) 49 | return(temp) 50 | } 51 | 52 | #' Available styles for mail template 53 | #' 54 | #' @param dataframe logical. FALSE by default. whether return a vector or a data frame. 55 | #' 56 | #' @return a vector or a dataframe. 57 | #' @export 58 | #' 59 | #' @examples mail_style() 60 | mail_style <- function(dataframe = FALSE){ 61 | temp <- c('casual', # (default), 62 | 'classic', 63 | 'oldstyle', 64 | 'banking' 65 | ) 66 | tempdf <- data.frame(i = 1:length(temp), 67 | template = temp) 68 | if (dataframe) return(tempdf) 69 | return(temp) 70 | } 71 | 72 | #' Available themes for mail template 73 | #' 74 | #' @param dataframe logical. FALSE by default. whether return a vector or a data frame. 75 | #' 76 | #' @return a vector or a dataframe. 77 | #' @export 78 | #' 79 | #' @examples mail_theme() 80 | mail_theme <- function(dataframe = FALSE){ 81 | temp <- c('blue', # (default), 82 | 'orange', 83 | 'green', 84 | 'red', 85 | 'purple', 86 | 'grey', # and 87 | 'black' 88 | ) 89 | tempdf <- data.frame(i = 1:length(temp), 90 | template = temp) 91 | if (dataframe) return(tempdf) 92 | return(temp) 93 | } 94 | 95 | #' Available fonts for mail body 96 | #' 97 | #' @param dataframe logical. FALSE by default. whether return a vector or a data frame. 98 | #' 99 | #' @return a vector or a dataframe. 100 | #' @export 101 | #' 102 | #' @examples mail_font() 103 | mail_font <- function(dataframe = FALSE){ 104 | temp <- c('sffamily', # (default), or 105 | 'calligra' 106 | ) 107 | tempdf <- data.frame(i = 1:length(temp), 108 | template = temp) 109 | if (dataframe) return(tempdf) 110 | return(temp) 111 | } 112 | 113 | #' Available fontsize for mail template 114 | #' 115 | #' @param dataframe logical. FALSE by default. whether return a vector or a data frame. 116 | #' 117 | #' @return a vector or a dataframe. 118 | #' @export 119 | #' 120 | #' @examples mail_fontsize() 121 | mail_fontsize <- function(dataframe = FALSE){ 122 | temp <- c('10pt', 123 | '11pt', 124 | '12pt' #(default) 125 | ) 126 | tempdf <- data.frame(i = 1:length(temp), 127 | template = temp) 128 | if (dataframe) return(tempdf) 129 | return(temp) 130 | } 131 | 132 | 133 | #' Available fontsize for mail body 134 | #' 135 | #' @param dataframe logical. FALSE by default. whether return a vector or a data frame. 136 | #' 137 | #' @return a vector or a dataframe. 138 | #' @export 139 | #' 140 | #' @examples mail_bodysize() 141 | mail_bodysize <- function(dataframe = FALSE){ 142 | temp <- c('tiny', 143 | 'scriptsize', 144 | 'footnotesize', 145 | 'small', 146 | 'normalsize', # (default), 147 | 'large', 148 | 'Large', 149 | 'LARGE', 150 | 'huge', 151 | 'Huge' 152 | ) 153 | tempdf <- data.frame(i = 1:length(temp), 154 | template = temp) 155 | if (dataframe) return(tempdf) 156 | return(temp) 157 | } 158 | 159 | #' Available themes for poster templatemail body 160 | #' 161 | #' @param dataframe logical. FALSE by default. whether return a vector or a data frame. 162 | #' 163 | #' @return a vector or a dataframe. 164 | #' @export 165 | #' 166 | #' @examples poster_theme() 167 | poster_theme <- function(dataframe = FALSE){ 168 | temp <- c('eco', # default 169 | 'ocean', 170 | 'rose', 171 | 'night', 172 | 'ice' 173 | ) 174 | tempdf <- data.frame(i = 1:length(temp), 175 | template = temp) 176 | if (dataframe) return(tempdf) 177 | return(temp) 178 | } 179 | 180 | #' Create demo files for building books with R bookdown package. 181 | #' 182 | #' @param template character. Choose a template for your book or doc. The default template is 'thesis_classic'. Available templates are (run `template()` for hints): 183 | #' - 'article', academic article, 184 | #' - 'article_mdpi', academic article by mdpi, 185 | #' - 'article_zh', academic article in Chinese, 186 | #' - 'calendar', monthly or weekly calendar, 187 | #' - 'chemistry', book with chemical molecular formulae and equations 188 | #' - 'chemistry_zh', chemistry book in Chinese, 189 | #' - 'discussion', article in discussion format, 190 | #' - 'guitar', book with guitar chords, 191 | #' - 'journal', laboratory journal or personal diary, 192 | #' - 'mail', personal or business mail, 193 | #' - 'nte_zh', a template from Nothing to envy, in Chinese 194 | #' - 'poem', poem book, 195 | #' - 'thesis_classic' (default), classic thesis, 196 | #' - 'thesis_mypku_zh', thesis of my Peking Uni., in Chinese, 197 | #' - 'thesis_ubt', thesis of University of Bayreuth, 198 | #' - 'thesis_zju_zh', thesis of Zhejiang Uni., in Chinese, 199 | #' - 'yihui_demo', the original demo book by Yihui Xie, 200 | #' - 'yihui_mini', a mini demo book by Yihui Xie, 201 | #' - 'yihui_zh', the demo in Chinese by Yihui Xie, 202 | #' - 'poster', poster. 203 | #' @param title character. book title. 204 | #' @param author character. book author. 205 | #' @param more_output optional output formats besides pdf_book, which can be (run `more_output()` for hints): 206 | #' - NULL (default) 207 | #' - 'word_document2' 208 | #' - 'html_document2' 209 | #' - 'epub_book' 210 | #' - 'gitbook' 211 | #' @param output_name chracter. the name of the output files. If NA (default), the template name will be used. 212 | #' @param render logical. whether to render automatically 213 | #' @param rproj logical. whether to created an .Rproj file automatically 214 | #' @param mail_opening character. opening of the mail, such as 'Dear Thomas, ' 215 | #' @param mail_closing character. closing of the mail, such as 'Yours, ' 216 | #' @param mail_from_address character. sender's address (Street and No.) for mail template 217 | #' @param mail_from_town character. sender's town for mail template 218 | #' @param mail_from_phone character. sender's phone number for mail templae 219 | #' @param mail_from_mobile character. sender's mobile phone number for mail templae 220 | #' @param mail_from_fax character. sender's fax number for mail templae 221 | #' @param mail_from_email character. sender's email for mail template 222 | #' @param mail_to_who character. recipient's name for mail template 223 | #' @param mail_to_affiliation character. recipient's affiliation (institute, university, etc.) for mail template 224 | #' @param mail_to_address character. recipient's address (Street and No.) for mail template 225 | #' @param mail_to_town character. recipient's town for mail template 226 | #' @param mail_date character. The date appearing in the mail 227 | #' @param mail_style character. The mail style for mail template. Available styles are (run `mail_style()` for hints): 228 | #' - 'casual' (default), 229 | #' - 'classic', 230 | #' - 'oldstyle', and 231 | #' - 'banking' 232 | #' @param mail_theme character. The mail theme for mail template. Available themes are (run `mail_theme()` for hints): 233 | #' - 'blue' (default), 234 | #' - 'orange', 235 | #' - 'green', 236 | #' - 'red', 237 | #' - 'purple', 238 | #' - 'grey', and 239 | #' - 'black' 240 | #' @param mail_font character. The font of the body for mail template. Available fonts are (run `mail_font()` for hints): 241 | #' - 'sffamily' (default), or 242 | #' - 'calligra' 243 | #' @param mail_fontsize character. fontsize of the mail for mail template. Available sizes are (run `mail_fontsize()` for hints): 244 | #' - '10pt', 245 | #' - '11pt', and 246 | #' - '12pt' (default) 247 | #' @param mail_bodysize character. fontsize of the mail body for mail template. Available sizes are (run `mail_bodysize()` for hints): 248 | #' - 'tiny', 249 | #' - 'scriptsize', 250 | #' - 'footnotesize', 251 | #' - 'small', 252 | #' - 'normalsize' (default), 253 | #' - 'large', 254 | #' - 'Large', 255 | #' - 'LARGE', 256 | #' - 'huge', 257 | #' - 'Huge'. 258 | #' 259 | #' @param poster_email character. author's email for poster template 260 | #' @param poster_institute character. for poster template 261 | #' @param poster_longinstitute character. for poster template 262 | #' @param poster_web character. for poster template 263 | #' @param poster_logo character. The path of the logo image. for poster template 264 | #' @param poster_backimg character. The path of the background image. for poster template 265 | #' @param poster_bibliofiles character. The path of the bib file for poster template 266 | #' @param poster_theme character. theme for poster template. available themes are 267 | #' - 'eco' (default), 268 | #' - 'ocean', 269 | #' - 'rose', 270 | #' - 'night', 271 | #' - 'ice'. 272 | #' @return demo files to build with bookdown 273 | #' @importFrom utils download.file unzip 274 | #' @export 275 | #' @examples 276 | #' bookdownplus(render = FALSE) 277 | #' bookdownplus(template = 'article', render = FALSE) 278 | #' @description 279 | #' Technically, `bookdownplus` is a collection and selector of R bookdown templates. `bookdownplus` helps you write academic journal articles, guitar books, chemical equations, mails, calendars, and diaries. R `bookdownplus` extends the features of `bookdown`, and simplifies the procedure. Users only have to choose a template, clarify the book title and author name, and then focus on writing the text. No need to struggle in YAML and LaTeX. 280 | #' 281 | #' Full documentation of `bookdownplus` can be found in the book [R bookdownplus Textbook](https://bookdown.org/baydap/bookdownplus). Here is a quick-start procedure. 282 | #' 283 | #' - Before starting, you have to install `bookdown` package, and other software and packages (i.e. 'Pandoc', 'LaTeX', `rmarkdown`, `rticle`, `knitr`, etc.) which `bookdown` depends on. See the [official manual of `bookdown`](https://bookdown.org/yihui/bookdown/) for details. Additionally, if you want to produce a poster, phython must be installed before using, and the path of phython might have to be added to the environmental variables for Windows users. 284 | #' 285 | #' - Run `bookdownplus()` and specify the template with `template` argument, You will get some files (e.g. `index.Rmd`, `body.Rmd`, `bookdownplus.Rproj`) and folders in your working directory. Although there are many other arguments for `bookdownplus()`, you can simply ignore them if you use `bookdownplus` package for the first time. 286 | #' - Open `bookdownplus.Rproj` with RStudio. Now press `ctrl+shift+b` to build it. Your will get a book file named `*.pdf` in `_book/` folder. 287 | #' - Write your own text in `index.Rmd` and `body.Rmd`, and build your own lovely book. 288 | bookdownplus <- function( ###### 289 | template = 'thesis_classic', 290 | more_output = NULL, 291 | title ='R bookdownplus', 292 | author = 'Peng Zhao', 293 | render = FALSE, 294 | rproj = FALSE, 295 | output_name = NA, 296 | # for mail template only 297 | mail_from_address = '15 Robin Hood Lane', 298 | mail_from_town = '11758 Massapequa, Long Island, New York', 299 | mail_from_phone = '31415926', 300 | mail_from_mobile = '31415927', 301 | mail_from_fax = '31415928', 302 | mail_from_email = 'test@test.test', 303 | mail_to_who = 'recipient', 304 | mail_to_affiliation = 'University of Innsbruck', 305 | mail_to_address = 'recipient address', 306 | mail_to_town = '100000 Beijing, China', 307 | mail_opening = 'Dear Sir or Madam,', 308 | mail_closing = 'Yours faithfully,', 309 | mail_date = '25 June, 2017', 310 | mail_style = c('casual', 'classic', 'oldstyle', 'banking')[1], 311 | mail_theme = c('blue', 'orange', 'green', 'red', 'purple', 'grey', 'black')[1], 312 | mail_font = c('sffamily', 'calligra ')[1], 313 | mail_fontsize = c('10pt', '11pt', '12pt')[3], 314 | mail_bodysize = c( 315 | 'tiny', 'scriptsize', 'footnotesize', 'small', 'normalsize', 316 | 'large', 'Large', 'LARGE', 'huge','Huge') [5], 317 | 318 | # for poster template only 319 | poster_email = 'test@test.test', 320 | poster_institute = 'Institute of Ecology, Univ. Innsbruck', 321 | poster_longinstitute = 'Institute of Ecology, University of Innsbruck, Austria', 322 | poster_web = 'pzhao.org', 323 | poster_logo = 'images/logo.png', 324 | poster_backimg = 'images/logo.png', 325 | poster_bibliofiles = 'bib/bib.bib', 326 | poster_theme = c('eco', 'ocean', 'rose')[1]) { 327 | pckpath <- paste0(path.package(package = 'bookdownplus'), '/') 328 | ###### internal functions ###### 329 | ### copy necessary files to the working directory 330 | copyfolder <- function(folder = 'images') { 331 | if (!dir.exists(folder)) dir.create(folder) 332 | mypath <- paste0(pckpath, folder) 333 | file.copy(from = dir(mypath[dir.exists(mypath)][1], full.names = TRUE), to = folder) 334 | } 335 | 336 | ### backup a file to backup/ folder, avoid overwriting it. 337 | backup <- function(filename, ifbackup = TRUE) { 338 | if (ifbackup) { 339 | if (file.exists(filename)) { 340 | filenamesplit <- strsplit(filename, '\\.')[[1]] 341 | filenamesplitl <- length(filenamesplit) 342 | tolength <- ifelse(filenamesplitl > 1, filenamesplitl - 1, 1) 343 | filenamepost <- filenamesplit[filenamesplitl] 344 | getwd() 345 | if (!dir.exists('backup')) dir.create('backup') 346 | backupfile <- paste0('backup/', paste(filenamesplit[1:tolength], collapse = '_'), '-', format(Sys.time(), '%Y-%m-%d-%H-%M-%S'), '.', filenamepost) 347 | file.copy(filename, backupfile) 348 | message(paste(filename, 'exsits. Backuped to', backupfile, ':)')) 349 | } #else { 350 | #message(paste(filename, 'does not exist. No need to bakcup :)')) 351 | #} 352 | } 353 | } 354 | 355 | ###### copy folders and files to the working dir ###### 356 | lapply(X = c('backup', 'bib', 'images'), FUN = copyfolder) 357 | backup('index.Rmd') 358 | 359 | unzip(paste0(pckpath, 'zip/', template, '.zip')) 360 | 361 | if (rproj) { 362 | mypath <- paste0(pckpath, 'proj/') 363 | file.copy(from = paste0(mypath[dir.exists(mypath)][1], 'bookdownplus'), to = 'bookdownplus.Rproj') 364 | } 365 | 366 | if (template == 'nte_zh') { 367 | if(!dir.exists('fonts')) dir.create('fonts') 368 | download.file('https://github.com/pzhaonet/bookdownplus/raw/master/fonts/fonts.zip', destfile = './fonts/fonts.zip') 369 | unzip('./fonts/fonts.zip', exdir = './fonts') 370 | file.remove('./fonts/fonts.zip') 371 | } 372 | 373 | ###### prepare index.Rmd ###### 374 | file.rename(paste0('index_', template, '.Rmd'), 'index.Rmd') 375 | index <- readLines('index.Rmd', encoding = 'UTF-8') 376 | index[grep('^title: "', index)] <- paste0('title: "', title, '"') 377 | index[grep('^author: "', index)] <- paste0('author: "', author, '"') 378 | # index[grep('titleshort: "', index)] <- paste0('titleshort: "', titleshort, '"') 379 | 380 | if (template == 'poster') { 381 | index[grep('^%% template=tex/poster.tex', index)] <- paste0('%% template=tex/poster_', poster_theme, '.tex') 382 | } 383 | writeLines(index, 'index.Rmd', useBytes = TRUE) 384 | 385 | if (template != 'poster') { 386 | ###### prepare _bookdown.yml, which defines the output filename of the book. ###### 387 | book_filename <- ifelse(is.na(output_name), template, output_name) 388 | filenameyml <- readLines(paste0(pckpath, 'yml/_bookdown.yml'), encoding = 'UTF-8') 389 | filenameyml[grep('book_filename: ', filenameyml)] <- paste0('book_filename: ', book_filename) 390 | backup('_bookdown.yml') 391 | writeLines(filenameyml, '_bookdown.yml', useBytes = TRUE) 392 | 393 | ###### prepare _output.yml, which defines the output files of gitbook and epub formats. comment it if you only need pdf. ###### 394 | backup('_output.yml') 395 | # file.copy('rmd/_output.yml', '_output.yml', copy.mode = FALSE, overwrite = TRUE) 396 | # output <- readLines('rmd/_output.yml') 397 | if (!is.null(more_output)) { 398 | outputyml <- file("_output.yml","w") 399 | for (ic in more_output) { 400 | writeLines(readLines(paste0(pckpath, 'yml/_output_', ic, '.yml')), con = outputyml, sep= "\n") 401 | } 402 | close(outputyml) 403 | } 404 | ###### prepare body.Rmd ###### 405 | for(i in c('body.Rmd', 'body.tex')) { 406 | backup(i) 407 | if(file.exists('body.Rmd')) file.remove(i) 408 | } 409 | bodydemo <- ifelse(template == 'calendar', 'body_calendar.tex', paste0('body_', template, '.Rmd')) 410 | bodynew <- paste0('body', substr(bodydemo, nchar(bodydemo)-3, nchar(bodydemo))) 411 | file.rename(bodydemo, bodynew) 412 | # file.copy(bodydemo, bodynew, copy.mode = FALSE, overwrite = TRUE) 413 | 414 | ###### exceptions ###### 415 | 416 | ### article_zh needs an additional abstract.tex file 417 | if (template %in% c('article_zh', 'article2_zh')) { 418 | backup('abstract.tex') 419 | file.copy(paste0('tex/template_', template, '_abstract.tex'), 'abstract.tex', copy.mode = FALSE, overwrite = TRUE) 420 | } 421 | 422 | ### mail needs an additional template_mail.tex as a before_body part. 423 | if (template == 'mail') { 424 | tmail <- readLines('tex/template_mail.tex') 425 | # tmail[51] <- paste0('{\\bfseries ', author, '}\\\\[.35ex]') 426 | # tmail[53] <- paste0(from_address, '\\\\') 427 | # tmail[54] <- paste0(from_town, '\\\\[.35ex]') 428 | # tmail[55] <- paste0('\\Telefon~', from_phone, '\\\\') 429 | # tmail[56] <- paste0('\\Letter~\\href{mailto:', from_email, '}{', from_email, '}') 430 | # 431 | # tmail[61] <- paste0('{\\bfseries ', to_who, '}\\\\[.35ex]') 432 | # tmail[63] <- paste0(to_address, '\\\\') 433 | # tmail[64] <- paste0(to_town, '\\\\[.35ex]') 434 | # 435 | # tmail[78] <- paste0('{\\bfseries ', author, '}\\\\') 436 | # tmail[75] <- paste(switch(type, 'business' = '\\sffamily', 'personal' = '\\calligra' ), 437 | # fontsize, sep = '\\') 438 | tmail[9] <- paste0('\\documentclass[', mail_fontsize, ',a4paper,sans]{style/moderncv}') 439 | tmail[12] <- paste0('\\moderncvstyle{', mail_style, '}') 440 | tmail[13] <- paste0('\\moderncvcolor{', mail_theme, '}') 441 | tmail[27] <- paste0('\\name{', author, '}{}') 442 | tmail[29] <- paste0('\\address{', mail_from_address, '}{', mail_from_town,'}{}') 443 | tmail[30] <- paste0('\\phone[mobile]{', mail_from_mobile, '}') 444 | tmail[31] <- paste0('\\phone[fixed]{', mail_from_phone, '}') 445 | tmail[32] <- paste0('\\phone[fax]{', mail_from_fax, '}') 446 | tmail[33] <- paste0('\\email{', mail_from_email, '}') 447 | tmail[54] <- paste0('\\recipient{', mail_to_affiliation, '}{',mail_to_address, '\\\\', mail_to_town, '}') 448 | tmail[55] <- paste0('\\date{', mail_date, '}') 449 | tmail[56] <- paste0('\\opening{', mail_opening, '}') 450 | tmail[57] <- paste0('\\closing{', mail_closing, '}') 451 | tmail[59] <- paste0('\\', mail_font, '\\', mail_bodysize) 452 | writeLines(tmail, 'tex/template_mail_user.tex') 453 | } 454 | 455 | ### article_mdpi needs an additional bst file 456 | if (template == 'article_mdpi') { 457 | file.copy('style/mdpi.bst', 'mdpi.bst') 458 | } 459 | 460 | if (render) { 461 | outfrmt <- paste0('bookdown::', c('pdf_book', more_output)) 462 | if(grepl('_dev', template)) outfrmt <- 'bookdown::pdf_book' 463 | bookdown::render_book( 464 | 'index.Rmd', 465 | output_format = outfrmt, clean = FALSE) 466 | htmlfile <- paste0(book_filename, '.html') 467 | bookdir <- '_book' 468 | if (file.exists(htmlfile)) { 469 | if (!dir.exists(bookdir)) dir.create(bookdir) 470 | file.copy(htmlfile, paste0(bookdir, '/', book_filename, '2.html')) 471 | file.remove(htmlfile) 472 | } 473 | 474 | mdfile <- paste0(book_filename, '.utf8.md') 475 | if (file.exists(mdfile)) { 476 | if (!dir.exists(bookdir)) dir.create(bookdir) 477 | file.copy(mdfile, paste0(bookdir, '/', paste0(book_filename, '.md'))) 478 | file.remove(mdfile) 479 | if (file.exists(paste0(book_filename, '.knit.md'))) file.remove(paste0(book_filename, '.knit.md')) 480 | if (file.exists(paste0(book_filename, '.lol'))) file.remove(paste0(book_filename, '.lol')) 481 | } 482 | 483 | } 484 | } 485 | } 486 | 487 | #' Show demos 488 | #' 489 | #' @param x NA or character, templates to show 490 | #' @param mail_all logical 491 | #' 492 | #' @return demo files 493 | #' @export 494 | #' 495 | #' @examples 496 | #' bd(x = NA) 497 | bd <- function(x = template()[-which(template() == 'poster')], mail_all = FALSE){ 498 | if('poster' %in% x) message('"poster" demo output will not be displayed automatcially. See the help.') 499 | if(.Platform$OS.type == 'unix') x <- x[x %in% c('article_mdpi', 'article', 'calendar', 'chemistry_zh', 'chemistry', 'discussion', 'dnd_dev', 'docsens', 'guitar', 'journal', 'mail', 'musix', 'nonpar', 'nte_zh', 'poem', 'rbasics', 'skak', 'thesis_classic', 'thesis_mypku_zh', 'thesis_pku_zh', 'thesis_ubt', 'thesis_zju_zh', 'yihui_crc', 'yihui_demo', 'yihui_mini', 'yihui_zh')] 500 | if(!is.na(x[1])) { 501 | for(i in x){ 502 | message(paste0('Generating a demo book from the "', i, '" template')) 503 | bookdownplus(template = i, more_output = more_output(), render = TRUE) 504 | message(paste0('Done with "', i, '"!')) 505 | } 506 | } else if(mail_all) { 507 | for(mf in mail_font()) { 508 | for(ms in mail_style()) { 509 | for(mt in mail_theme()) { 510 | bookdownplus(template = 'mail', mail_style = ms, mail_font = mf, mail_theme = mt, output_name = paste('mail', ms, mf, mt, sep = '_'), render = TRUE) 511 | } 512 | } 513 | } 514 | } else { 515 | message('No template in the showcase.') 516 | } 517 | } 518 | 519 | #' Prepare a template to contribute to bookdownplus 520 | #' 521 | #' @param template_name character. tempalte name. 522 | #' @param bodyfile character. name of the body file. 523 | #' @param indexfile character. name of the index file. 524 | #' @param texfile character. name of the texfile 525 | #' 526 | #' @return organzed folders and files. 527 | #' @export 528 | #' 529 | #' @examples 530 | #' share() 531 | share <- function(template_name = 'new', bodyfile = 'body.Rmd', indexfile = 'index.Rmd', texfile = 't.tex'){ 532 | folders <- c('rmd', 'style', 'tex') 533 | files <- paste0(c('body_', 'index_', 'template_'), template_name, c('.Rmd', '.Rmd', '.tex')) 534 | for(i in folders) if(!dir.exists(i)) dir.create(i) 535 | pckpath <- paste0(path.package(package = 'bookdownplus'), '/') 536 | mypath <- paste0(pckpath, 'proj/') 537 | for (i in c('body.Rmd', 'index.Rmd')) file.copy(from = paste0(mypath[dir.exists(mypath)][1], i), to = i) 538 | if(file.exists(texfile)) file.copy(texfile, paste0('tex/', files[3])) else message(paste(texfile, 'does not exist.')) 539 | if(file.exists(bodyfile)) file.copy(bodyfile, paste0('rmd/', files[1])) else message(paste(bodyfile, 'does not exist.')) 540 | if(file.exists(indexfile)) { 541 | indextxt <- readLines(indexfile, encoding = 'UTF-8') 542 | indextxt[grep('template', indextxt)] <- gsub('new', template_name, indextxt[grep('template', indextxt)]) 543 | writeLines(indextxt, indexfile, useBytes = TRUE) 544 | file.copy(indexfile, paste0('rmd/', files[2])) 545 | } else message(paste(indexfile, 'does not exist.')) 546 | } 547 | --------------------------------------------------------------------------------