簡體   English   中英

在markdown / knitr`中制作pdf文檔時如何包裝長字符串

[英]How to wrap a long string when making a pdf document in markdown/knitr`

我有一個 Rmd 腳本,可以讀取文件進行處理。 作為報告的一部分,我正在打印該文件的路徑以保持清晰和一致性。 當該文件被大量嵌套(在多個文件夾內)時,文件路徑的長度變得太長而無法在一行上打印。 有沒有辦法在 Rmd 代碼中強制斷字,如果路徑長於單行顯示,它將在 2 行上打印路徑?

示例:

---
title: "Test"
author: "Test"
date: "10/13/2016"
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(tidy = TRUE)
```

#Set Variable
```{r VarDef}
File <- "~/Documents/Data/StudyData/WGS/FolderName1/FolderName2/FolderName3/ExtraLongBacteriaName_Details_pass_2D.fasta"
```


This is a test RMD file as an example. The file name causing issue is:

**`r File`**

I would like to be able to have this name break at the end of the page and continue on a second line.

我在嘗試將 R markdown 文件編織為 PDF 時遇到了同樣的問題。 所有代碼解決方案都不起作用,但我注意到當代碼被換行時,R 在行號中留下了一個空格(例如第 345 行、空格、第 346 行)。 這意味着該行已換行。

您可以通過在沒有數字的行的開頭單擊 Enter 來解開它。 新行是 345、346 和 347)

我為整個代碼做了這個,現在它編織得很好!

暫無
暫無

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

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