考慮以下玩具回饋表:
\documentclass{article}
\usepackage{hyperref}
\renewcommand*{\DefaultHeightofTextMultiline}{20\baselineskip}
\begin{document}
\centering
\begin{Form}
\TextField[multiline,width=\textwidth,
value={%
You should write your feedback in a readable way, for example using bullet points:
* Insert at least 1 positive comment (mandatory)
* Insert at least 1 critical comment or question (mandatory)
\newline
Use multiple paragraphs.
\newline
Some examples of concrete, actionable feedback:
* The first figure does not have a caption; please add it.
* The derivation of Equation (7) became unclear around Equation (5). I think this is because you did not make the substitution of x explicit and feel doing so would make the argument clearer.%
},
name=mytextfield]{}%
\end{Form}
\end{document}
使用 pdflatex 編譯此檔案會出現以下警告(兩次,每次一個\newline
):
Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref) removing `\newline' on input line 20.
這並不令我感到驚訝,因為對於透過 hyperref 創建和填充的大多數 pdf 欄位來說,換行是沒有意義的,並且可能不受支援。但是,透過編輯表單並保存結果檔案(在我的例子中使用 Okular),我能新增換行符。當使用從表單中取得資料時PythonPDF2的PdfFileReader.getFields
方法,我得到:
'You should write your feedback in a readable way, for example using bullet points:\n* Insert at least 1 positive comment (mandatory)\n* Insert at least 1 critical comment or question (mandatory)\n\nUse multiple paragraphs.\n\nSome examples of concrete, actionable feedback:\n* The first figure does not have a caption; please add it.\n* The derivation of Equation (7) became unclear around Equation (5). I think this is because you did not make the substitution of x explicit and feel doing so would make the argument clearer.'
注意換行符\n
。所以這似乎是可能的。我想在我的 LaTeX 檔案中添加這些換行符。這可能嗎?我怎樣才能做到這一點?
我天真地嘗試添加文字\n
as \textbackslash{n}
,但失敗了:
'You should write your feedback in a readable way, for example using bullet points:\\n * Insert at least 1 positive comment (mandatory)\\n * Insert at least 1 critical comment or question (mandatory)\\n \\n Use multiple paragraphs.\\n \\n Some examples of concrete, actionable feedback:\\n * The first figure does not have a caption; please add it.\\n * The derivation of Equation (7) became unclear around Equation (5). I think this is because you did not make the substitution of x explicit and feel doing so would make the argument clearer.'
答案1
更新\textCR
:實際上使用或更好\textLF
。如果編碼發生變化,它們也將起作用。
\string\n
對我有用:
\documentclass{article}
\usepackage{hyperref}
\renewcommand*{\DefaultHeightofTextMultiline}{20\baselineskip}
\begin{document}
\centering
\begin{Form}
\TextField[multiline,width=\textwidth,
value={%
You should write your feedback in a readable way, for example using bullet points:\string\n
* Insert at least 1 positive comment (mandatory)\string\n
* Insert at least 1 critical comment or question (mandatory)\string\n
Use multiple paragraphs.
\string\n
Some examples of concrete, actionable feedback:\string\n
* The first figure does not have a caption; please add it.\string\n
* The derivation of Equation (7) became unclear around Equation (5). I think this is because you did not make the substitution of x explicit and feel doing so would make the argument clearer.\string\n%
},
name=mytextfield]{}%
\end{Form}
\end{document}