Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

设置 copyrightpage 以后 tikz external 的 pdf 中会带有 copyrightpage 的背景 #693

Closed
jiegec opened this issue Jul 10, 2021 · 5 comments

Comments

@jiegec
Copy link
Member

jiegec commented Jul 10, 2021

编译环境

编译的系统:macOS 10.14
TeX 发行版:MiKTeX 21.2
模板版本:v7.2.2
模板类型:bachelor

描述问题

设置了 \copyrightpage 为 授权文件后,tikz external 生成的 thesis-figure%d.pdf 中可以看到授权文件作为背景,tikz 画图内容作为前景。

复现上述问题的代码:

\copyrightpage[file=scan-copyright.pdf]
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize
@zepinglee
Copy link
Contributor

给个完整的示例?我没用过 tikz

jiegec added a commit to jiegec/thuthesis that referenced this issue Jul 10, 2021
@jiegec
Copy link
Member Author

jiegec commented Jul 10, 2021

@zepinglee
Copy link
Contributor

我可以复现了。

\documentclass[degree=bachelor]{thuthesis}

\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize

\begin{document}

\copyrightpage[file=figures/scan-copyright.pdf]

\begin{figure}[htbp]
  \centering
  \begin{tikzpicture}
      \draw[step=1cm,gray,very thin] (0,0) grid (10,10);
  \end{tikzpicture}
\end{figure}

\end{document}

@zepinglee
Copy link
Contributor

zepinglee commented Jul 10, 2021

感觉是 tikz/pdfpages 的 bug,因为用标准文档类也能复现。

\documentclass{article}

\usepackage{pdfpages}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize

\begin{document}

\includepdf{example-image-a4.pdf}

\begin{tikzpicture}
  \draw[step=1cm,gray,very thin] (0,0) grid (10,10);
\end{tikzpicture}

\end{document}

不用 pdfpages
Screen Shot 2021-07-10 at 19 09 27

使用 pdfpages
Screen Shot 2021-07-10 at 19 09 53

@zepinglee
Copy link
Contributor

这个是 tikz 的兼容性问题,见文档「52.8.2 Compatibility With Other Libraries or Packages」:
Screen Shot 2021-07-11 at 11 04 09
这里给的解决方案有些奇怪,可以修改为:

\tikzifexternalizing{%
  \renewcommand*\includepdf[2][]{}
}{}%

我打算把这部分添加到模板中( 1e26b19 ),目前可以修复 f1b0286 的示例( 688c8d2 ),需要再测试下有没有别的问题。

另外一种解决办法参考 pgf-tikz/pgf#78https://tex.stackexchange.com/a/160670/82731 设置 external/optimize command away

\tikzexternalize[optimize command away=\includepdf]

@zepinglee zepinglee changed the title 设置 copyrightpage 以后 tikz external 的 pdf 中会带有 copyrightpage 的北京 设置 copyrightpage 以后 tikz external 的 pdf 中会带有 copyrightpage 的背景 Jul 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants