Forgot password?
 Create new account
View 145|Reply 0

\write18写入文本

[Copy link]

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

hbghlyj Posted at 2023-5-7 00:47:08 |Read mode
在Windows命令行运行
  1. echo 123>1.txt
Copy the Code

可以往1.txt写入123 (不带引号)
可以在LaTeX中使用\write18
  1. \documentclass{article}
  2. \pagestyle{empty}
  3. \begin{document}
  4. \mbox{}
  5. \write18{echo 123>1.txt}
  6. \end{document}
Copy the Code

使用latex 1.tex --enable-write18 --shell-escape编译
可以看到1.txt写入了文本123

但若把文本123改成1
在Windows命令行运行
  1. echo 1>1.txt
Copy the Code

1.txt的内容就变成
ECHO is on.
为什么不是1呢

手机版Mobile version|Leisure Math Forum

2025-4-20 22:20 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list