我是 Ti 新手钾Z 和我在居中 Ti 时遇到了问题钾Z 图片相对于其标题(以及页边距)的大小。通过激活图片的background rectangle
,似乎在图片的顶部和右侧都添加了额外的空白(矩形居中,但图片不在)。
其他 Ti 没有出现同样的问题钾同一文档中的 Z 张图片。
以下是代码:
\documentclass[11pt]{article}
\usepackage{showframe} % Activate to show the page margins
\usepackage{tikz}
\usetikzlibrary{intersections, backgrounds, shapes, arrows, shadows}
\begin{document}
\begin{figure*}[!ht]
\centering
% \includegraphics[width=0.30\textwidth]{Figure03.png}
\begin{tikzpicture}
[show background rectangle]
% Fading settings
\tikzfading[name = fade out
, inner color = transparent!100
, outer color = transparent!10 ]
% Axes
\draw [->, >=stealth] (0,0) -- (-0.6,-0.6) node[anchor=north west]{$X$};
\draw [->, >=stealth] (0,0) -- (1.2,0) node[anchor=north]{$Y$};
\draw [->, >=stealth] (0,0) -- (0,1.2) node[anchor=east]{$Z$};
% Ellipse filling
\fill [ color = cyan
, opacity = 0.25
, path fading = fade out
, fading angle = -30
, rotate = -30]
(0,0) ellipse (1.5cm and 3.0cm);
% Ellipse
\draw [ name path = ellipse 1
, rotate = -30]
(0,0) ellipse (1.5cm and 3.0cm);
% Oblique axis
\draw [ name path = oblique axis
, dashed]
(-2.5,-1.3) node[anchor=south east]{$a$} -- (2.5,1.3);
% Intersection
\path [name intersections={of=ellipse 1 and oblique axis}] ;
\fill [color=red] (intersection-1) circle (0.6mm)
node[anchor=north west]{$A$};
\draw [thick, ->, >=stealth] (0,0) -- (intersection-1);
% Origin
\fill (0,0) circle (0.6mm);
\draw (0,0) node[anchor=north west]{$O$};
\end{tikzpicture}
\caption{Ellipsoid of inertia.}\label{figure:fig03}
\end{figure*}
\end{document}
答案1
出现错误是因为 ,\tikzfading
而与 无关background rectangle
。我想您可能在一个简单的 中遇到同样的问题\fbox
。您可以在以下 MWE 中看到这一点:
% arara: pdflatex
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{backgrounds,shadows}
\begin{document}
\begin{tikzpicture}[show background rectangle]
\fill (0,0) circle (5mm);
\end{tikzpicture}
\begin{tikzpicture}[show background rectangle]
\tikzfading[name=test]
\fill (0,0) circle (5mm);
\end{tikzpicture}
\end{document}
或者甚至更好(表明这backgrounds
不是罪魁祸首),例如:
% arara: lualatex
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shadows}
\usepackage{lua-visual-debug}
\begin{document}
\begin{tikzpicture}
\fill (0,0) circle (5mm);
\end{tikzpicture}
\begin{tikzpicture}
\tikzfading[name=test]
\fill (0,0) circle (5mm);
\end{tikzpicture}
\end{document}
一个简单的解决方法是将 放入\tikzfading
前言中或放在图片前面。我不知道这个库的手册,但我猜这是推荐的使用方式。
% arara: pdflatex
\documentclass[11pt]{article}
\usepackage{showframe}
\usepackage{tikz}
\usetikzlibrary{%
,intersections
,backgrounds
,shadows
}
\tikzset{>=stealth}
\begin{document}
\begin{figure}[!ht]
\centering
% Fading settings
\tikzfading[%
,name = fade out
,inner color = transparent!100
,outer color = transparent!10
]
\begin{tikzpicture}[show background rectangle]
% Axes
\draw [->] (0,0) -- (-0.6,-0.6) node[anchor=north west]{$X$};
\draw [->] (0,0) -- (1.2,0) node[anchor=north]{$Y$};
\draw [->] (0,0) -- (0,1.2) node[anchor=east]{$Z$};
% Ellipse
\filldraw [%
,draw = black
,fill = cyan
,fill opacity = 0.25
,path fading = fade out
,fading angle = -30
,name path = ellipse 1
,rotate = -30
]
(0,0) ellipse (1.5cm and 3.0cm);
% Oblique axis
\draw [name path = oblique axis,dashed](-2.5,-1.3) node[anchor=south east]{$a$} -- (2.5,1.3);
% Intersection
\path [name intersections={of=ellipse 1 and oblique axis}];
\fill [color=red] (intersection-1) circle (0.6mm) node[anchor=north west]{$A$};
\draw [thick, ->, >=stealth] (0,0) -- (intersection-1);
% Origin
\fill (0,0) circle (0.6mm) node[anchor=north west]{$O$};
\end{tikzpicture}
\caption{Ellipsoid of inertia.}\label{figure:fig03}
\end{figure}
\end{document}