![如何\immediate\write 使用 \newline 和 \StrSubstitute 生成的多行](https://linux22.com/image/470348/%E5%A6%82%E4%BD%95%5Cimmediate%5Cwrite%20%E4%BD%BF%E7%94%A8%20%5Cnewline%20%E5%92%8C%20%5CStrSubstitute%20%E7%94%9F%E6%88%90%E7%9A%84%E5%A4%9A%E8%A1%8C.png)
为什么这\newline
当使用(而不是^^J
)和 生成行时不起作用,\StrSubstitute
如下所示?谢谢
\documentclass{article}
\usepackage{xstring}
\begin{document}
\def\mystrings{\noindent\StrSubstitute{%
B; new; test old; found people; sun; atom; number; life}%
{; }{\noexpand\noexpand\noexpand\newline}}
\mystrings
% B
% new
% test old
% found people
% sun
% atom
% number
% life
\newwrite\file
\immediate\openout\file=mystrings.txt
\immediate\write\file{\mystrings}
\closeout\file
\end{document}
答案1
目前还不清楚你想要什么,但也许
\documentclass{article}
\begin{document}
\def\mystrings{ B; new; test old; found people; sun; atom; number; life}%
\newwrite\file
\immediate\openout\file=mystrings.txt
{\newlinechar=`;
\immediate\write\file{\mystrings}
}
\closeout\file
\end{document}
生成文件
B
new
test old
found people
sun
atom
number
life