mdwtools的語法包和graphicx之間的交互不良

mdwtools的語法包和graphicx之間的交互不良

我正在編寫一個文檔,我想透過 包含一些圖像graphicx\includegraphics使用syntax套件顯示一些 BNF 語法,但是當我嘗試將它們一起使用時,mdwtools我收到錯誤undefined control sequence帶有一些檔案名

一個失敗的最小例子:

\documentclass{article}

\usepackage{syntax}
\usepackage{graphicx}

\begin{document}

\includegraphics{logo_uniud_black}

\end{document}

編譯這個我得到以下錯誤:

(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
! Undefined control sequence.
\filename@simple ...#2\\}\fi \edef \filename@base 
                                                  {#1}
l.8 \includegraphics{logo_uniud_black}

   [omissis]

! Undefined control sequence.
\filename@simple ...#2\\}\fi \edef \filename@base 
                                                  {#1}
l.8 \includegraphics{logo_uniud_black}

(That makes 100 errors; please try again.)

註解掉\usepackage{syntax}可以解決問題。也可以使用不包含下劃線的檔案名,這樣程式碼就不會失敗:

\documentclass{article}

\usepackage{syntax}
\usepackage{graphicx}

\begin{document}

\includegraphics{logouniudblack}

\end{document}

為什麼會出現此錯誤?有沒有辦法修復它而不重命名我必須包含的所有文件?


編輯:

實際上,即使是帶下劃線的節名也會產生問題,因此\include會引發類似的錯誤,例如原始碼:

\documentclass{article}

\usepackage{syntax}

\begin{document}

\include{sintassi_astratta}

\end{document}

我收到這些錯誤:

(/usr/share/texlive/texmf-dist/tex/latex/mdwtools/syntax.sty) (./bad_doc.aux)
! Undefined control sequence.
\GenericError  ...                                
                                                    #4  \errhelp \@err@     ...
l.7 \include{sintassi_astratta}

! Undefined control sequence.
\GenericError  ...                                
                                                  \let \@err@               ...
l.7 \include{sintassi_astratta}

! Undefined control sequence.
\GenericError  ...                                
                                                  \@empty \def \MessageBreak...
l.7 \include{sintassi_astratta}

! Undefined control sequence.
\GenericError  ...                                
                                                     \endgroup 
l.7 \include{sintassi_astratta}

! Argument of \reserved@b has an extra }.
<inserted text> 
                \par 
l.7 \include{sintassi_astratta}

Runaway argument?
{\usc@builtindischyphen }\futurelet \@let@token \@ifnch astratta.aux
! Paragraph ended before \reserved@b was complete.
<to be read again> 
                   \par 
l.7 \include{sintassi_astratta}

(./sintassi.tex)
! Missing control sequence inserted.
<inserted text> 
                \inaccessible 
l.7 \include{sintassi_astratta}

! Too many }'s.
\@filef@und ...\@let@token \let \discretionary {-}
                                                  {}{}\discretionary {-}{}{}...
l.7 \include{sintassi_astratta}

[1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] (./sintassi.tex)
Runaway text?
\@setckpt{sintassi\protect \unhbox \voidb@x \kern .06em\vbox {\hrule \ETC.
! File ended while scanning text of \write.
<inserted text> 
                }
l.7 \include{sintassi_astratta}

! Unbalanced write command.
<write> ... \@setckpt {sintassi_astratta}\@charlb 

l.7 \include{sintassi_astratta}

(./bad_doc.aux
Runaway argument?
{sintassi\protect \global \let \OT 1\textunderscore \unhbox \voidb@x \ETC.
! Paragraph ended before \@input was complete.
<to be read again> 
                   \par 
l.5 

! Missing { inserted.
l.7 ...or immediate help   \endgroup {}\def \par }

)

LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.

! Missing } inserted.
<inserted text> 
                }
l.9 \end{document}

! Missing } inserted.
<inserted text> 
                }
l.9 \end{document}

! Extra \endgroup.
<recently read> \endgroup 

l.9 \end{document}

 )

如果我沒記錯的話,不是尋找而是sintassi_astratta.tex尋找sintassi.tex。似乎syntax正在以某種破壞一切的方式重新定義下劃線。

答案1

syntax包有一個nounderscore選項;然後您需要使用\_複合名稱。

如果您希望了解數學模式之外的_含義,請使用\_

\input{\detokenize{file_name}}

對於\includeor也類似\includegraphics。所以

\documentclass{article}

\usepackage[nounderscore]{syntax}
\usepackage{graphicx}

\begin{document}

\includegraphics{logo_uniud_black}

\end{document}

也能正常運作

\documentclass{article}

\usepackage{syntax}
\usepackage{graphicx}

\begin{document}

\includegraphics{\detokenize{logo_uniud_black}}

\end{document}

答案2

用於\string_底線

\includegraphics{/tmp/logo\string_uniud\string_black}

相關內容