我希望在部分标题页(PTP)中插入由 tikz 生成的图片。
在下面的最小工作示例我定义了一个名为 \newcommand\地理使用 tikz 生成绘图。然后我在 PTP 之前调用 \geo,但自动出现分页符,将图像留在 PTP 之前的页面上。
是否可以避免分页,以便图像和标题位于同一页面上?
\documentclass[a4paper,14pt,twoside,reqno]{extbook}
\usepackage[margin=28mm]{geometry}
\usepackage{amsmath,amssymb,amsthm,mathpazo}
\usepackage[english]{babel}
\usepackage{titlesec}
\usepackage{tocloft, etoolbox}
\usepackage{tikz, ifthen, bclogo}
%----------<<< tikz example >>>----------
\newcommand{\geo} {
\usetikzlibrary {shapes.geometric}
\begin{tikzpicture}
\node (start) [draw,shape=ellipse] {};
\foreach \angle in {-180, -178, ..., 180}
\draw (node cs:name=start,angle=\angle)
.. controls +(\angle:5cm) and +(0,0) .. (0,5);
\end{tikzpicture}
}
%----------<<< tikz 示例结束 >>>-------
\begin{document}
\pagestyle{plain}
\begin{center}
\geo
\end{center}
\part{Special Functions.}
\end{document}
答案1
这个答案就是解决方案:https://tex.stackexchange.com/users/4427/egreg
\documentclass[a4paper,14pt,twoside,reqno]{extbook}
\usepackage[margin=28mm]{geometry}
\usepackage{amsmath,amssymb,amsthm,mathpazo}
\usepackage[english]{babel}
\usepackage{titlesec}
\usepackage{tocloft, etoolbox}
\usepackage{tikz, ifthen, bclogo}
\usetikzlibrary {shapes.geometric}
% ----------<<< tikz example >>>----------
\newcommand{\geo} {
\begin{tikzpicture}
\node (start) [draw,shape=ellipse] {};
\foreach \angle in {-180, -178, ..., 180}
\draw (node cs:name=start,angle=\angle)
.. controls +(\angle:5cm) and +(0,0) .. (0,5);
\end{tikzpicture}
}
% ----------<<< END of tikz example >>>----------
% ----------<<< Definition of absolutelynopagebreak by egreg >>>----------
\newenvironment{absolutelynopagebreak}
{\par\nobreak\vfil\penalty0\vfilneg
\vtop\bgroup}
{\par\xdef\tpd{\the\prevdepth}\egroup
\prevdepth=\tpd}
% ----------<<< END of Definition of absolutelynopagebreak >>>----------
\begin{document}
\pagestyle{plain}
\begin{absolutelynopagebreak}
\part{Special functions.}
\begin{center}
\geo
\end{center}
\end{absolutelynopagebreak}
\end{document}