我的代码:
\documentclass{scrartcl}
\usepackage{stanli}
\usetikzlibrary{angles,
quotes
}
\newcommand*\coordinateSystem{\draw
[<->] (7, 0) node[right] {$x$} -|
(6, 1) node[above] {$y$};
\draw
[->] (6, -.5) arc (-90 : 180 : .5);
}
\begin{document}
\input{virtual_displacement_system}\\[\baselineskip]
%contains:
%\begin{tikzpicture}[trim left = { (0, 0) }]
%%the points and their names
%%A
%\point{begin}{0}{0};
%\notation{1}{begin}{$A$}[above = 50pt];
%%B
%\point{middle}{2.5}{0};
%\notation{1}{middle}{$B$}[above = 50pt];
%%C
%\point{end}{5}{0};
%\notation{1}{end}{$C$}[above = 50pt];
%%the beam
%\beam{2}{begin}{end};
%%the support
%\support{1}{begin};
%\hinge{1}{begin};
%\dimensioning{1}{begin}{middle}{1.5}[$l$];
%\dimensioning{1}{middle}{end}{1.5}[$l$];
%%the load and their names
%%M
%\load{2}{begin};
%\notation{1}{begin}{$M$}[above right = 10pt];
%%G
%\load{1}{middle}[90];
%\notation{1}{middle}{$G$};
%%F
%\load{1}{end}[-90];
%\notation{1}{end}{$F$}[below right];
%\coordinateSystem
%\end{tikzpicture}
$M$ und $G$ seien bekannt. Gesucht ist $F$ und die Auflagerreaktionen. Freischnitt:\\[\baselineskip]
\input{virtual_displacement_free_body_diagram}\\[\baselineskip]
%contains:
%\begin{tikzpicture}[trim left = { (0, 0) }]
%the points
%\point{begin}{0}{0};
%\point{middle}{2.5}{0};
%\point{end}{5}{0};
%%the beam
%\beam{2}{begin}{end};
%%the load and their names
%%A_x
%\load{1}{begin}[180];
%\notation{1}{begin}{$A_x$}[left = 30pt];
%%A_y
%\load{1}{begin}[-90];
%\notation{1}{begin}{$A_y$}[below right];
%%M
%\load{2}{begin};
%\notation{1}{begin}{$M$}[above right = 10pt];
%%G
%\load{1}{middle}[90];
%\notation{1}{middle}{$G$};
%%F
%\load{1}{end}[-90];
%\notation{1}{end}{$F$}[below right];
%\coordinateSystem
%\end{tikzpicture}
Virtuelle Verschiebungen:\\[\baselineskip]
\input{virtual_displacement}
%contains:
%\begin{tikzpicture}[trim left = { (0, 0) }]
%%the points
%\point{begin}{0}{0};
%\point{end}{5}{0};
%the beam
%\begin{scope}[dashed]
%\beam{2}{begin}{end};
%\end{scope}
%%the displaced points
%\point{delta_begin}{.5}{.5};
%\point{delta_end}{5.5}{1};
%%the displaced beam
%\beam{2}{delta_begin}{delta_end};
%%virtual displacements
%\dimensioning{2}{begin}{delta_begin}{0}[$\delta y$];
%\dimensioning{1}{begin}{delta_begin}{.5}[$\delta x$];
%\draw
%[dashed] (delta_begin) -- (5.5, .5);
%%angle between the beam and displaced beam
%\coordinate (A) at (5.5, .5);
%\coordinate (B) at (delta_begin);
%\coordinate (C) at (delta_end);
%\pic[draw,
%angle radius = 45mm,
%angle eccentricity = .9,
%"$\delta \varphi$"
%] {angle};
%\coordinateSystem
%\end{tikzpicture}
\end{document}
结果:
有没有办法通过A
上图中的点将三张图片对齐?简而言之:
提前感谢您的帮助和努力!
答案1
这是另一个我无法解释为什么事情会失败的案例,但我可以指出如何使其发挥作用。
不要使用\\[\baselineskip]
(这无论如何都是不受欢迎的),而是通过在图表前后添加一行空代码来开始一个新段落。(如果你总是添加\\[baselineskip]
你做错的事情,我认为正确的方法是使用\documentclass[parskip=full]{scrartcl}
,并用空行开始新段落。)
首先考虑这个简化的例子:
\documentclass{article}
\usepackage{tikz}
\usepackage{showframe} % to indicate text area bounds
\usepackage{parskip} % set zero parindent and some parskip
\newcommand\demodiagram[1]{%
\begin{tikzpicture}[trim left=(a)]
\coordinate (a);
\fill (a) circle[radius=2pt];
\draw [<->] (a) +(-#1,0) -- +(2*#1,0);
\end{tikzpicture}}
\begin{document}
Here we have paragraph breaks before and after the diagrams.
\demodiagram{1}
\demodiagram{2}
And it works as expected.
But this\\
\demodiagram{1}\\
does not\\
\demodiagram{2}\\
work.
\end{document}
输出如下所示:
因此,您可以看到,由于您使用的结构(即使用 的换行符)的原因,此操作失败\\
。
用您的代码完成示例。
在下面的代码块中,我为您的代码实现了相同的功能,但我还演示了第二种方法,即添加类似于
\useasboundingbox (-2,2.5) rectangle (7.5,-1);
在每个 的开头tikzpicture
。当在图表的最开始处添加时,这可以让您手动设置边界框。要对齐多个图表,您只需确保第一个坐标的 x 分量在所有tikzpicture
s 中都相同。其他值需要针对每个图表单独调整。
这种方法不如 方便trim left
,但好处是图表不会突出到左边距。(取决于您为最左边的坐标选择的 x 值。)
% note the parskip=full parameter which disables paragraph indentation
% and sets some vertical space between paragraphs.
\documentclass[parskip=full]{scrartcl}
\usepackage{stanli}
\usetikzlibrary{angles,
quotes,backgrounds
}
\newcommand*\coordinateSystem{\draw
[<->] (7, 0) node[right] {$x$} -|
(6, 1) node[above] {$y$};
\draw
[->] (6, -.5) arc (-90 : 180 : .5);
}
\usepackage{showframe}
\begin{document}
On this page \texttt{trim left} is applied.
% \input{virtual_displacement_system}
%contains:
\begin{tikzpicture}[trim left=(begin)]
%%the points and their names
%%A
\point{begin}{0}{0};
\notation{1}{begin}{$A$}[above = 50pt];
%%B
\point{middle}{2.5}{0};
\notation{1}{middle}{$B$}[above = 50pt];
%%C
\point{end}{5}{0};
\notation{1}{end}{$C$}[above = 50pt];
%%the beam
\beam{2}{begin}{end};
%%the support
\support{1}{begin};
\hinge{1}{begin};
\dimensioning{1}{begin}{middle}{1.5}[$l$];
\dimensioning{1}{middle}{end}{1.5}[$l$];
%%the load and their names
%%M
\load{2}{begin};
\notation{1}{begin}{$M$}[above right = 10pt];
%%G
\load{1}{middle}[90];
\notation{1}{middle}{$G$};
%%F
\load{1}{end}[-90];
\notation{1}{end}{$F$}[below right];
\coordinateSystem
\end{tikzpicture}
$M$ und $G$ seien bekannt. Gesucht ist $F$ und die Auflagerreaktionen. Freischnitt:
% \input{virtual_displacement_free_body_diagram}
%contains:
\begin{tikzpicture}[trim left=(begin)]
%the points
\point{begin}{0}{0};
\point{middle}{2.5}{0};
\point{end}{5}{0};
%%the beam
\beam{2}{begin}{end};
%%the load and their names
%%A_x
\load{1}{begin}[180];
\notation{1}{begin}{$A_x$}[left = 30pt];
%%A_y
\load{1}{begin}[-90];
\notation{1}{begin}{$A_y$}[below right];
%%M
\load{2}{begin};
\notation{1}{begin}{$M$}[above right = 10pt];
%%G
\load{1}{middle}[90];
\notation{1}{middle}{$G$};
%%F
\load{1}{end}[-90];
\notation{1}{end}{$F$}[below right];
\coordinateSystem
\end{tikzpicture}
Virtuelle Verschiebungen:
% \input{virtual_displacement}
%contains:
\begin{tikzpicture}[trim left=(begin)]
%the points
\point{begin}{0}{0};
\point{end}{5}{0};
%the beam
\begin{scope}[dashed]
\beam{2}{begin}{end};
\end{scope}
%the displaced points
\point{delta_begin}{.5}{.5};
\point{delta_end}{5.5}{1};
%the displaced beam
\beam{2}{delta_begin}{delta_end};
%virtual displacements
\dimensioning{2}{begin}{delta_begin}{0}[$\delta y$];
\dimensioning{1}{begin}{delta_begin}{.5}[$\delta x$];
\draw
[dashed] (delta_begin) -- (5.5, .5);
%angle between the beam and displaced beam
\coordinate (A) at (5.5, .5);
\coordinate (B) at (delta_begin);
\coordinate (C) at (delta_end);
\pic[draw,
angle radius = 45mm,
angle eccentricity = .9,
"$\delta \varphi$"
] {angle};
\coordinateSystem
\end{tikzpicture}
\newpage
On this page the \verb|\useasboundingbox| macro is demonstrated.
% \input{virtual_displacement_system}
%contains:
\begin{tikzpicture}
\useasboundingbox (-2,2.5) rectangle (7.5,-1);
%%the points and their names
%%A
\point{begin}{0}{0};
\notation{1}{begin}{$A$}[above = 50pt];
%%B
\point{middle}{2.5}{0};
\notation{1}{middle}{$B$}[above = 50pt];
%%C
\point{end}{5}{0};
\notation{1}{end}{$C$}[above = 50pt];
%%the beam
\beam{2}{begin}{end};
%%the support
\support{1}{begin};
\hinge{1}{begin};
\dimensioning{1}{begin}{middle}{1.5}[$l$];
\dimensioning{1}{middle}{end}{1.5}[$l$];
%%the load and their names
%%M
\load{2}{begin};
\notation{1}{begin}{$M$}[above right = 10pt];
%%G
\load{1}{middle}[90];
\notation{1}{middle}{$G$};
%%F
\load{1}{end}[-90];
\notation{1}{end}{$F$}[below right];
\coordinateSystem
\end{tikzpicture}
$M$ und $G$ seien bekannt. Gesucht ist $F$ und die Auflagerreaktionen. Freischnitt:
% \input{virtual_displacement_free_body_diagram}
%contains:
\begin{tikzpicture}
\useasboundingbox (-2,1.5) rectangle (7.5,-1);
%the points
\point{begin}{0}{0};
\point{middle}{2.5}{0};
\point{end}{5}{0};
%%the beam
\beam{2}{begin}{end};
%%the load and their names
%%A_x
\load{1}{begin}[180];
\notation{1}{begin}{$A_x$}[left = 30pt];
%%A_y
\load{1}{begin}[-90];
\notation{1}{begin}{$A_y$}[below right];
%%M
\load{2}{begin};
\notation{1}{begin}{$M$}[above right = 10pt];
%%G
\load{1}{middle}[90];
\notation{1}{middle}{$G$};
%%F
\load{1}{end}[-90];
\notation{1}{end}{$F$}[below right];
\coordinateSystem
\end{tikzpicture}
Virtuelle Verschiebungen:
% \input{virtual_displacement}
%contains:
\begin{tikzpicture}
\useasboundingbox (-2,1.5) rectangle (7.5,-0.7);
%the points
\point{begin}{0}{0};
\point{end}{5}{0};
%the beam
\begin{scope}[dashed]
\beam{2}{begin}{end};
\end{scope}
%the displaced points
\point{delta_begin}{.5}{.5};
\point{delta_end}{5.5}{1};
%the displaced beam
\beam{2}{delta_begin}{delta_end};
%virtual displacements
\dimensioning{2}{begin}{delta_begin}{0}[$\delta y$];
\dimensioning{1}{begin}{delta_begin}{.5}[$\delta x$];
\draw
[dashed] (delta_begin) -- (5.5, .5);
%angle between the beam and displaced beam
\coordinate (A) at (5.5, .5);
\coordinate (B) at (delta_begin);
\coordinate (C) at (delta_end);
\pic[draw,
angle radius = 45mm,
angle eccentricity = .9,
"$\delta \varphi$"
] {angle};
\coordinateSystem
\end{tikzpicture}
\end{document}