我無法確定 hyperref 和 hypdvips 之間的錯誤

我無法確定 hyperref 和 hypdvips 之間的錯誤

請看下面的最小非工作範例。這是不正確的,因為將建立輸出 pdf。然而日誌檔會產生錯誤。我花了很多時間,但我仍然不確定是否是我的錯。

我已經下載了全新的 MiKTeX 2.9.5105 分發便攜版本並更新了軟體包。我用 dvi-ps-pdf 批次檔進行編譯

這是 MWE

\documentclass{scrreprt}
\usepackage[utf8]{inputenc} % Uses the utf8 input encoding
\usepackage{hyperref}
\usepackage{hypdvips}

\begin{document}
\chapter*{Impressum}
\chapter{Zu diesem Dokument}
Dieses Installationsanleitung erläutert alle Themen um den -Client installieren zu     können und ist als Leitfaden mit Zusatzinformationen aufgebaut. Bestimmte abgebildete windowsspezifische Programmelemente können in den Windowsversionen abweichen, gelten aber sinngemäß. 
\section{Symbole und Auszeichnungen}

\section{Want to use command from package hypdvips}
\attachfile[description={MNWEB.log},flags=0000000001, mimetype=application/txt]{MNWEB.log}
\end{document}  

錯誤文件顯示以下錯誤。

LaTeX Info: Redefining \ref on input line 25.
LaTeX Info: Redefining \pageref on input line 25.
LaTeX Info: Redefining \nameref on input line 25.
 [2


]
Chapter 1.
! Missing \endcsname inserted.
<to be read again> 
               \@ne 
l.29  \section
          {Symbole und Auszeichnungen}
The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Missing \endcsname inserted.
<to be read again> 
               \@ne 
l.29  \section
          {Symbole und Auszeichnungen}
The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Missing \endcsname inserted.
<to be read again> 
               \BKM@style@\@ne  
l.29  \section
              {Symbole und Auszeichnungen}
The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Extra \endcsname.
\KVS@ProcessorDefault ...sname KV@#1@#2\endcsname 
                                              \unless \ifcsname KVS@#1@h...
l.29  \section
              {Symbole und Auszeichnungen}
I'm ignoring this, since I wasn't doing a \csname.


! Package kvsetkeys Error: Undefined key `\BKM@style@\@ne  '.

See the kvsetkeys package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.29  \section
          {Symbole und Auszeichnungen}
The keyval family of the key `\BKM@style@\@ne  ' is `BKM'.
The setting of the key is ignored because of the error.

Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.

Package atveryend Info: Executing hook `BeforeClearDocument' on input line 30.
[3

如果沒有人看到我的錯誤,那麼它可能是一個錯誤,我會在查看幾天後報告。

最佳重修生

編輯2:

使用此命令進行編譯。

set B=C:\tex\miktex\bin\
set gs_path=d:\peter\Programme\gs\gs9.10\bin\
%B%latex --enable-write18 --src -interaction=nonstopmode --save-size=80000 MWE.tex
%B%dvips -P pdf -D1200 MWE.dvi"
%gs_path%gswin32c.exe -sPAPERSIZE=a4 -dNOSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFileMWE.pdf -c save pop -f MWE.ps

彼得

答案1

使用時會出現錯誤scrreprt,因為它定義了

% scrreprt.cls, line 2874:
\newcommand\section{%
  \@startsection{section}{\sectionnumdepth}{\z@}%
  {-3.5ex \@plus -1ex \@minus -.2ex}%
  {2.3ex \@plus.2ex}%
  {\ifnum \scr@compatibility>\@nameuse{scr@[email protected]}\relax
    \setlength{\parfillskip}{\z@ plus 1fil}\fi
    \raggedsection\normalfont\sectfont\nobreak\size@section}%
}

並且

% scrreprt.cls, line 2397:
\newcommand*{\sectionnumdepth}{\@ne}

當建立該部分的書籤時,\BKM@currentlevel透過定義

\xdef\BKM@currentlevel{<second argument to \startsection>}

在這種情況下給出的結果與

\gdef\BKM@currentlevel{\@ne}

因為\@ne是不可擴展的。但然後\BKM@currentlevel在裡面使用\csname...\endcsname,哪裡\@ne都是非法的。

這是一個修復(由 Heiko Oberdiek 提出):載入hypdvips更改後如何\@startsection重新定義

\makeatletter
\def\@startsection#1#2#3#4#5#6{%
  \bookmarksetup{style=pp@bmstyle@empty}%
  \ifx\@M#2%
    \xdef\BKM@currentlevel{1}%
  \else
    \xdef\BKM@currentlevel{\number#2}%
  \fi
  \@ifundefined{BKM@style@\BKM@currentlevel}{}{\bookmarksetup{style=\BKM@currentlevel}}%
  \pp@backup@@startsection{#1}{#2}{#3}{#4}{#5}{#6}%
}
\makeatother

一個也許更簡單的解決方法是修補\section以具有\number\sectionnumdepth

\documentclass{scrreprt}
\usepackage[utf8]{inputenc} % Uses the utf8 input encoding
\usepackage{etoolbox}
\usepackage[pdfencoding=auto]{hyperref} % don't forget the option
\usepackage{hypdvips}

\patchcmd{\section}{\sectionnumdepth}{\number\sectionnumdepth}{}{}

\begin{document}

\chapter*{Impressum}

\chapter{Zu diesem Dokument} 

Dieses Installationsanleitung erläutert alle Themen um den -Client installieren 
zu können und ist als Leitfaden mit Zusatzinformationen aufgebaut. Bestimmte 
abgebildete windowsspezifische Programmelemente können in den Windowsversionen 
abweichen, gelten aber sinngemäß.

\section{Symbole und Auszeichnungen}

\section{Want to use command from package hypdvips}
\attachfile[description={MNWEB.log},flags=0000000001, mimetype=application/txt]{MNWEB.log}
\end{document}  

相關內容