对齐两个垂直子浮动

对齐两个垂直子浮动

基本上这个问题(在子浮点中垂直对齐两个 tikzpicture),但适用于垂直放置的子浮点数。

baseline我知道如果它们彼此相邻,您可以使用选项对齐它们,但我不知道如何水平对齐它们。

我希望虚线是垂直的,即通过对齐节点。

我希望虚线是垂直的,即通过对齐节点。

\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{subfig}
\usepackage{pgfplots}
\usetikzlibrary{positioning}
\begin{document}
\begin{figure}
\centering
\newcommand{\length}{400}
\subfloat[Bovenaanzicht]{
    \begin{tikzpicture}[x=.250mm,y=.250mm,remember picture]
    % Afmeting van inlet
    \draw[<->] (0, 45) -- (0, -45) node[left,midway] {90mm};
    % Afmeting outlet
    \draw[<->] (\length + 40, 45) -- (\length + 40, -45) node[right,midway] {90mm};
    % Afmeting fan
    \draw[<->] (65, .5*65) -- (65, -.5*65) node[left,midway] {65mm};

    % Tube
    \draw (0,45) -- (65, 0.5*65) -- (65+42, 0.5*65) -- (\length, 45);
    \draw (0,-45) -- (65, -0.5*65) -- (65+42, -0.5*65) -- (\length, -45);
    \node (fanpositionl bovenaanzicht) at (65, 0.5*65){};
    \node (fanpositionr bovenaanzicht) at (65+42, 0.5*65){};
    \end{tikzpicture}
}
\par
\subfloat[Zijaanzicht]{
    \begin{tikzpicture}[x=.250mm,y=.250mm,remember picture]
    % Tube
    \draw (0,37) -- (65, 65) -- (65+42, 65) -- (\length, 32);
    \draw (0,0) -- (\length, 0);
    \node (fanpositionl zijaanzicht) at(65, 0) {};
    \node (fanpositionr zijaanzicht) at(65+42, 0) {};
    \end{tikzpicture}
}
\begin{tikzpicture}[x=.250mm,y=.250mm,overlay,remember picture]
\draw[dashed] (fanpositionl zijaanzicht) -- (fanpositionl bovenaanzicht);
\draw[dashed] (fanpositionr zijaanzicht) -- (fanpositionr bovenaanzicht);
\end{tikzpicture}
\caption{Profiel van ``Elliptische'' duct}\label{fig:motorschacht_elliptisch}
\end{figure}
\end{document}

答案1

您需要使图片看起来与 大小相同。这可以通过和tikz完全或部分设置边界框来实现。 trim lefttrim right

示例输出

\documentclass{article}

\usepackage{tikz}
\usepackage{amsmath}
\usepackage{subfig}
\usepackage{pgfplots}
\usetikzlibrary{positioning}
\pgfplotsset{compat=1.12}

\begin{document}
\begin{figure}
\centering
\newcommand{\length}{280}
\subfloat[Bovenaanzicht]{
  \begin{tikzpicture}[x=.250mm,y=.250mm,trim left,trim right=200,
    remember picture]
    % Afmeting van inlet
    \draw[<->] (0, 45) -- (0, -45) node[left,midway] {90mm};
    % Afmeting outlet
    \draw[<->] (\length + 40, 45) -- (\length + 40, -45)
      node[right,midway] {90mm};
    % Afmeting fan
    \draw[<->] (65, .5*65) -- (65, -.5*65) node[left,midway] {65mm};

    % Tube
    \draw (0,45) -- (65, 0.5*65) -- (65+42, 0.5*65) -- (\length, 45);
    \draw (0,-45) -- (65, -0.5*65) -- (65+42, -0.5*65) -- (\length, -45);
    \node (fanpositionl bovenaanzicht) at (65, 0.5*65){};
    \node (fanpositionr bovenaanzicht) at (65+42, 0.5*65){};
    \end{tikzpicture}
}\\
\subfloat[Zijaanzicht]{
\begin{tikzpicture}[x=.250mm,y=.250mm,trim left,trim right=200,
  remember picture]
  % Tube
  \draw (0,37) -- (65, 65) -- (65+42, 65) -- (\length, 32);
  \draw (0,0) -- (\length, 0);
  \node (fanpositionl zijaanzicht) at(65, 0) {};
  \node (fanpositionr zijaanzicht) at(65+42, 0) {};
\end{tikzpicture}
}
\begin{tikzpicture}[x=.250mm,y=.250mm,remember picture,overlay]
\draw[dashed] (fanpositionl zijaanzicht) -- (fanpositionl bovenaanzicht);
\draw[dashed] (fanpositionr zijaanzicht) -- (fanpositionr bovenaanzicht);
\end{tikzpicture}
\caption{Profiel van ``Elliptische'' duct}\label{fig:motorschacht_elliptisch}
\end{figure}


\end{document}

我已经减少了你的\length变量,以便图片适合页面。

答案2

问题是第一张图片比 宽,\textwidth所以它突出到右边距。为了防止这种情况,一个选项是缩小你的tikzpictures (我使用了scale=0.85)。另外,请注意,你有一些虚假的空白,我在我的代码中使用 消除了它们%

\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{subfig}
\usepackage{pgfplots}
\usetikzlibrary{positioning}

\begin{document}

\begin{figure}
\centering
\newcommand{\length}{400}
\subfloat[Bovenaanzicht]{%
    \begin{tikzpicture}[x=.250mm,y=.250mm,remember picture,scale=0.85]
    % Afmeting van inlet
    \draw[<->] (0, 45) -- (0, -45) node[left,midway] {90mm};
    % Afmeting outlet
    \draw[<->] (\length + 40, 45) -- (\length + 40, -45) node[right,midway] {90mm};
    % Afmeting fan
    \draw[<->] (65, .5*65) -- (65, -.5*65) node[left,midway] {65mm};

    % Tube
    \draw (0,45) -- (65, 0.5*65) -- (65+42, 0.5*65) -- (\length, 45);
    \draw (0,-45) -- (65, -0.5*65) -- (65+42, -0.5*65) -- (\length, -45);
    \node (fanpositionl bovenaanzicht) at (65, 0.5*65){};
    \node (fanpositionr bovenaanzicht) at (65+42, 0.5*65){};
    \end{tikzpicture}%
}
\par
\subfloat[Zijaanzicht]{%
    \begin{tikzpicture}[x=.250mm,y=.250mm,remember picture,scale=0.85]
    % Tube
    \draw (0,37) -- (65, 65) -- (65+42, 65) -- (\length, 32);
    \draw (0,0) -- (\length, 0);
    \node (fanpositionl zijaanzicht) at(65, 0) {};
    \node (fanpositionr zijaanzicht) at(65+42, 0) {};
    \end{tikzpicture}%
}
\begin{tikzpicture}[x=.250mm,y=.250mm,overlay,remember picture]
\draw[dashed] (fanpositionl zijaanzicht) -- (fanpositionl bovenaanzicht);
\draw[dashed] (fanpositionr zijaanzicht) -- (fanpositionr bovenaanzicht);
\end{tikzpicture}
\caption{Profiel van ``Elliptische'' duct}\label{fig:motorschacht_elliptisch}
\end{figure}

\end{document}

在此处输入图片描述

相关内容