很抱歉再次打扰大家——这是我之前的问题的后续问题:
(我想我可以把它和之前的问题结合起来,但这似乎是原始问题的一个“陷阱”。)虽然我有一个解决方案,但当使用带有变音符号的文件名时它会中断和使用 latin1/utf8 输入编码时。MWE 会得到一个额外的行(以打破它):
\usepackage[latin1]{inputenc}
或者
\usepackage[utf8]{inputenc}
每种情况下的错误都不同。由于它有效没有inputenc 包,我很想说“只需删除这一行,看看会发生什么。”
我环顾四周,发现了以下问题(似乎最为相关):
那里的讨论似乎说 inputenc 会将变音符号更改为 tex 宏。因此 ö 变成了 \"o 等。
我的问题是,这种扩展是否会破坏下面处理星号/空格替换的代码?如果是这样,那么我是否需要用循环来扩展/替换 \scantokens 宏以检查此额外条件?真恶心!
梅威瑟:
% "test öffnen.tex"
% Variations in run command to illustrate a more specific requirement ...
% Without {inputenc}
% Works: >h:\MikTeX\MikTeX.2.9p\texmf\miktex\bin\pdflatex "test öffnen.tex"
% Works: >h:\MikTeX\MikTeX.2.9p\texmf\miktex\bin\pdflatex "-job-name=test oeffnen" "test öffnen.tex"
% Works: >h:\MikTeX\MikTeX.2.9p\texmf\miktex\bin\pdflatex "-job-name=test öffnen" "test öffnen.tex"
% BROKEN with \usepackage[latin1]{inputenc}
% BROKEN with \usepackage[utf8]{inputenc}
% >h:\MikTeX\MikTeX.2.9p\texmf\miktex\bin\pdflatex "-job-name=test öffnen" "test öffnen.tex"
% Same run-command as above, different package
\pdfoutput=1
\documentclass[german]{article}
\usepackage[a4paper]{geometry}
\usepackage{babel}
\usepackage[T1]{fontenc}
%%%\usepackage[latin1]{inputenc}
%%% jobname=test*öffnen
%%% ! TeX capacity exceeded, sorry [input stack size=5000].
%%% \font@name ->
%%% \T1/cmr/m/n/10
%%% l.27 ...scantokens\expandafter{\JobnameX\noexpand}
%%% }
%%% If you really absolutely need more capacity,
%%% you can ask a wizard to enlarge me.
%%%\usepackage[utf8]{inputenc}
%%% produces error on console: pdflatex: Windows API error 1113: No mapping for the Unicode character exists in the target multi-byte code page.
\typeout{jobname=\jobname}
% Convert jobname
\edef\JobnameX{\jobname}
\catcode`\*=\active
\def*{ }
\edef\JobnameX{\scantokens\expandafter{\JobnameX\noexpand}}
\catcode`\*=12 %
\newcommand{\TestFilename}{\JobnameX .ips}
\typeout{TestFilename=\TestFilename}
%%%
%%%
\begin{document}
%%% Write stuff to output - then read it back into a pdfobj
\newwrite\MyFilehandle
\immediate\openout\MyFilehandle="\TestFilename"
\typeout{Test writing stuff to output file=\TestFilename}
\immediate\write\MyFilehandle{Test writing stuff to output file=\TestFilename}
\immediate\closeout\MyFilehandle
\immediate\pdfobj file {\TestFilename} %%% Just to show a snapshot of the entire process.
%%% FYI - we embed papertray/bursting/external page requirement commands for postprocessing
%%% (actually written as a 'pagepiece' dictionary)
%%%
%%% Write some text to create a pdf
Write some text into the pdf.
\end{document}
\endinput
使用 latin1 时的错误提示我应该扩展 TeXs 堆栈。我想我可以这样做 - 只是我不相信这是问题所在。这似乎更像是一种症状。