裁剪 TikZ 显示

裁剪 TikZ 显示

我有两条相交线和一条从这两条线的交点开始的射线的显示。我使用路径命令

\path[name path = left.side] (-3.75,-3.75) -- (-3.75,3.75);

\path[name path = right.side] (3.75,-3.75) -- (3.75,3.75);

以及 Intersections 包在两条垂直线之间绘制这些线。如何裁剪顶部和底部空间?我只包括命令

\draw (current bounding box.south west) grid (current bounding box.north east);

显示有多少空间被浪费了。

\documentclass{amsart}

\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes}

\usepackage{adjustbox}
\usepackage{mathtools}


\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\begin{document}

\begin{tikzpicture}

\coordinate (Q) at (0,0);
\node[fill=white,circle,inner sep=0pt] (Q-label) at ($(Q)+(-90:10pt)$) {$Q$};

\coordinate (R) at ($(Q) +(3.75,0)$);
\draw[-latex] (Q) -- (R);
\node at ($(R)+(0:10pt)$) {$m$};


\path[name path = ell.up] (0,0) -- (25:5);
\path[name path = ell.down] (0,0) -- (-155:5);
\path[name path= k.up] (0,0) -- (165:5);
\path[name path = k.down] (0,0) -- (-15:5);

%The following commands are for placing drawing the lines, placing the
%arrowheads at the ends of the line segments. The drawn lines are to be
%bound between the vertical lines $x = -3.75$ and $x = 3.75$. Since
%$\ell$ has the steeper slope, the height of the bounding box is determined
%by $\ell$.
\path[name path = left.side] (-3.75,-3.75) -- (-3.75,3.75);
\path[name path = right.side] (3.75,-3.75) -- (3.75,3.75);

\path[name intersections={of= left.side and ell.down, by=aa/ell}];%left.side.ell.down
\path[name intersections={of= right.side and ell.up, by=bb/ell}];%right.side.ell.up

\draw[draw=blue!30,latex-latex] (aa/ell) -- (bb/ell);


\path[name intersections={of= left.side and k.up, by=aa/k}];%left.side.k.down
\path[name intersections={of= right.side and k.down, by=bb/k}];%right.side.k.up

\draw[draw=green!50,latex-latex] (aa/k) -- (bb/k);

%These commands put the labels on lines $\ell$ and $k$.
\node at ($(bb/ell)+(25:10pt)$) {$\ell$};
\node at ($(bb/k)+(-15:10pt)$) {$k$};

%These commands label the angles.
\path pic[angle radius=5mm,"$\scriptstyle{40}$",angle eccentricity=1.25] {angle = aa/k--Q--aa/ell};
\path pic[angle radius=10mm,"$\scriptstyle{25}$",angle eccentricity=1.25] {angle = R--Q--bb/ell};
\path pic[angle radius=10mm,"$\scriptstyle{x}$",angle eccentricity=1.25] {angle = bb/k--Q--R};

%This command draws a dot at point Q; the dot is drawn over the two lines.
\draw[fill] (Q) circle (1.5pt);

\draw[line width=0.1pt, draw=gray!25] (current bounding box.south west) grid (current bounding box.north east);
\end{tikzpicture}

\end{document}

答案1

选项overlay帮助:

\path[overlay, name path = left.side] (-3.75,-3.75) -- (-3.75,3.75);
\path[overlay, name path = right.side] (3.75,-3.75) -- (3.75,3.75);

那么这些路径语句中的点将不会被考虑用于边界框的计算。

结果

并且也overlay适用于其他\path[name ...]命令:

结果

相关内容