请考虑以下玩具反馈表:
\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),我能添加换行符。使用PyPDF2的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
为\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}