pstricks 无法与论文模板配合使用

pstricks 无法与论文模板配合使用

我一直在尝试让 pst-optexp 包与我拥有的论文模板一起工作,但这简直是一场噩梦。

我正在使用 MikTeX 和 pdflatex 编译,如前所述如何在 pdfLaTeX 中使用 PSTricks?我已经设置了 -enable-write18 标志。

\input{head/settings_thesis_template.tex}

\begin{document}
\include{main/optical_exp}
\end{document}

并且 settings_thesis_template.tex 如下所示:

\documentclass[a4paper,11pt,fleqn]{book}
\usepackage{etex}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french,german,english]{babel}
\usepackage{fourier} 
\usepackage{setspace} % increase interline spacing slightly
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{bm} 
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{mdwlist}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{booktabs}
\usepackage{lipsum}
\usepackage{microtype}
\usepackage{url}
\usepackage[final]{pdfpages}
\usepackage{fancyhdr}
\usepackage{listings}
\usepackage{hyperref}
\usepackage{color}
\usepackage{tikz}
\usetikzlibrary[topaths]
\usetikzlibrary{positioning,calc,arrows}

\usepackage[explicit]{titlesec}

\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{auto-pst-pdf}
\usepackage{pst-optexp}
\usepackage{pstricks-add}
\usepackage{pst-pdf}

optical_exp.tex 中包含的图像如下:

\begin{pspicture}(-1.5,-1.5)(1.5,1.5)
\pnode(-1,0){in}
\pnode(0,0){mir}
\pnode(1,0){out}
\pnode(-1,-1){low}
\pnode(-1,1){high}
\mirror(low)(mir)(high)
\drawbeam[linecolor=red,arrows=->](in){1}(in)
\end{pspicture}

最后,我得到了 1) 论文文件 pdf,以及 2) 一个空白的、自动生成的 pdf,其中应该包含“optical_exp-tex”中的图像。

有趣的是,XeTex 能够编译这个 MWE。但是,当我尝试使用 XeTeX 编译更复杂的论文模板时,我得到了一堆 unicode 错误,如下所示:

Unicode char \u8:èse not set up for use with LaTeX
Unicode char \u8:éle not set up for use with LaTeX.

我的文件编码确实是 UTF-8,并且我已经包含了与此错误相关的软件包,您可以在我的“设置”文件中看到。(感谢该帖子inputenc 错误:Unicode 字符 \u8:未设置为与 LaTeX 一起使用)。这可能是我文档中的法语文本,但我不明白为什么尽管有“解决方法”包,但仍然会出现此错误。

所以问题是:1)为什么 pdflatex 不能与我的 MWE 一起使用,2)为什么 XeTex 会给我 UTF-8 编码错误?

对这些问题的任何见解都非常受欢迎!

答案1

我阅读了 tug.org 上 PSTricks 网站上的文档,显然将 tikz 和 pstricks 一起使用是一个常见错误。作者提供了一种解决方法像这样,用于将 pst-plot 与 tikz 结合使用。

对于我的具体示例,我必须添加

\usepackage{auto-pst-pdf}
\ifpdf
  \usepackage{tikz}
\else
  \usepackage{pst-optexp}
\fi

在序言中的之后紧接着\documentclass,并删除另一个\usepackage{tikz}

相关内容