小頁環境中的垂直和水平對齊

小頁環境中的垂直和水平對齊

在本例中,如何才能使圖形與頁面的兩個頁邊距之間具有相同的間距: 在此輸入影像描述

另外,我想用右 tikzpicture 的軸心調整左圖的底邊x:怎麼做?

感謝您的幫助,

此致,

代碼 :

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{pgfplots}
\usepackage{pgf, tikz, adjustbox}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{angles,calc}
\usetikzlibrary{spy}
\usetikzlibrary{patterns, matrix, positioning}
\usetikzlibrary{decorations.markings, decorations.pathreplacing, arrows.meta,
                patterns.meta,
                quotes}
\usetikzlibrary{shapes.geometric}
 %%HYPERBOLE   
    \newcommand\tikzhyperbola[6][thick]{%
    \draw [#1, rotate around={#2: (0, 0)}, shift=#3]
        plot [variable = \t, samples=1000, domain=-#6:#6] ({#4 / cos( \t )}, {#5 * tan( \t )});
        }

\begin{document}

\begin{figure}[h]
  \centering
  \begin{minipage}[t]{0.45\textwidth} % Définition de la taille de la première colonne
    \centering
    \includegraphics[width=\linewidth]{example-image}
    \caption*{Image 1}
    \vspace{1em} % Ajoutez de l'espace vertical si nécessaire
  \end{minipage} % Fin de la première colonne
  \hfill % Espace horizontal entre les deux colonnes
  \begin{minipage}[t]{0.5\textwidth} % Définition de la taille de la deuxième colonne
    \centering
    \begin{tikzpicture}[scale=0.45,
    the_angle/.style args = {#1/#2}{draw,latex-latex,
                                   angle radius=#1,
                                   angle eccentricity=#2,
                                   }, % angle label position
                                   ]
    
    \tikzset{
        elli/.style args={#1:#2and#3}{
            draw,
            shape=ellipse,
            rotate=#1,
            minimum width=2*#2,
            minimum height=2*#3,
            outer sep=0pt,
        }
    }
    \def\angle{90}
    \def\bigaxis{1.5cm}
    \def\smallaxis{1.5cm}
    \def\bigaxisbis{2.9cm}
    \def\smallaxisbis{3.6cm}
    
    \pgfmathsetmacro\axisratio{\smallaxis / \bigaxis}
    
    \coordinate (center) at (0, 0);
    
    \node [scale=0.55, elli=\angle:\bigaxis and \smallaxis, line width = 1.2pt, color=black, dotted] at (center) (e) {};
    
    \draw [-{stealth}, line width = 0.8pt, color = black] ([shift={(\angle:0)}] e.center) -- ([shift={(\angle:8)}] e.center) node [above right] {$z$};
    \draw [-{stealth}, line width = 1pt, color = black] ([shift={(0:-8)}] e.center) -- ([shift={(0:8)}] e.center) node [above left]  {$x$}  ;
    
    \draw[blue!80!black, very thick, Stealth-Stealth] (\bigaxis,0) --node[fill=white,scale = .65,right,xshift = 0.1 cm]{$h_{0}(t)$} (\bigaxis,\smallaxis);
    \draw[blue!80!black, dashed, thin] (0,\smallaxis) -- (\bigaxis,\smallaxis);
    \draw[red!80!black, very thick, Stealth-Stealth] (\bigaxisbis,0) --node[fill=white,scale = .65,right,xshift = 0.1 cm]{$h_{0}(t+\delta t)$} (\bigaxisbis,2.95cm);
    \draw[red!80!black, dashed, thin] (0,2.875cm) -- (3cm,2.95cm);
     % Dessin des 2 hyperboles
    \tikzhyperbola[line width = 1.2pt, color=blue!80!black]{\angle}{(center)}{\bigaxis}{\smallaxis}{77}
    \tikzhyperbola[line width = 1.2pt, color=red!80!black]{\angle}{(center)}{\bigaxisbis}{\smallaxisbis}{62}
    % asymptotes
    \def\lengthofasymptote{15}
            \coordinate (O) at (0,0); % intersection with coordinate axis
            \coordinate (C) at (-2,0);        
    % Dessin de l'arc de cercle entre CO et l'asymptote
    \draw[stealth-stealth, color=black, line width = 0.4pt]
        let \p1=($(O)-(C)$),\n1={veclen(\x1,\y1)} in
        (O) ++(135: \n1) arc (135:180: \n1) node[pos=0.5, above left] {$\alpha$};
    % asymptotes
    \draw [color=black!40, line width = 0.4pt, rotate around={45: (center)}]
        ($ (0, 0) + (center) $) --++(0.75*\lengthofasymptote, 0) ;
    \draw [color=black!40, line width = 0.4pt, rotate around={ 135: (center)}]
        ($ (0, 0) + (center) $) -- ++(0.75*\lengthofasymptote, 0) ;
    \end{tikzpicture}
    \caption*{Image 2}
    \vspace{1em} % Ajoutez de l'espace vertical si nécessaire
  \end{minipage} % Fin de la deuxième colonne
  \caption{Légende générale pour les deux figures}
  \label{fig:exemple_figures_alignees}
\end{figure}

\end{document}

編輯:我嘗試實現baseline垂直對齊數字,但我犯了一個錯誤,因為它無法正常工作。

代碼 :

\begin{figure}[h]
  \centering
  \begin{minipage}[t]{0.4\textwidth} % Définition de la taille de la première colonne
    \centering
    \includegraphics[width=\linewidth]{example-image}
    \caption*{Image 1}
    \vspace{1em} % Ajoutez de l'espace vertical si nécessaire
  \end{minipage} % Fin de la première colonne
  \hfill % Espace horizontal entre les deux colonnes
  \begin{minipage}[t][\dimexpr\height+\depth\relax]{0.5\textwidth} % Définition de la taille de la deuxième colonne avec la même hauteur que l'image
    \centering
    \begin{tikzpicture}[baseline=(current bounding box.south),scale=0.45,
    the_angle/.style args = {#1/#2}{draw,latex-latex,
                                   angle radius=#1,
                                   angle eccentricity=#2,
                                   }, % angle label position
                                   ]  % BASELINE HERE
    \tikzset{
        elli/.style args={#1:#2and#3}{
            draw,
            shape=ellipse,
            rotate=#1,
            minimum width=2*#2,
            minimum height=2*#3,
            outer sep=0pt,
        }
    }
    \def\angle{90}
    \def\bigaxis{1.5cm}
    \def\smallaxis{1.5cm}
    \def\bigaxisbis{2.9cm}
    \def\smallaxisbis{3.6cm}
    
    \pgfmathsetmacro\axisratio{\smallaxis / \bigaxis}
    
    \coordinate (center) at (0, 0);
    
    \node [scale=0.55, elli=\angle:\bigaxis and \smallaxis, line width = 1.2pt, color=black, dotted] at (center) (e) {};
    
    \draw [-{stealth}, line width = 0.8pt, color = black] ([shift={(\angle:0)}] e.center) -- ([shift={(\angle:8)}] e.center) node [above right] {$z$};
    \draw [-{stealth}, line width = 1pt, color = black] ([shift={(0:-8)}] e.center) -- ([shift={(0:8)}] e.center) node [above left]  {$x$}  ;
    
    \draw[blue!80!black, very thick, Stealth-Stealth] (\bigaxis,0) --node[fill=white,scale = .65,right,xshift = 0.1 cm]{$h_{0}(t)$} (\bigaxis,\smallaxis);
    \draw[blue!80!black, dashed, thin] (0,\smallaxis) -- (\bigaxis,\smallaxis);
    \draw[red!80!black, very thick, Stealth-Stealth] (\bigaxisbis,0) --node[fill=white,scale = .65,right,xshift = 0.1 cm]{$h_{0}(t+\delta t)$} (\bigaxisbis,2.95cm);
    \draw[red!80!black, dashed, thin] (0,2.875cm) -- (3cm,2.95cm);
     % Dessin des 2 hyperboles
    \tikzhyperbola[line width = 1.2pt, color=blue!80!black]{\angle}{(center)}{\bigaxis}{\smallaxis}{77}
    \tikzhyperbola[line width = 1.2pt, color=red!80!black]{\angle}{(center)}{\bigaxisbis}{\smallaxisbis}{62}
    % asymptotes
    \def\lengthofasymptote{15}
            \coordinate (O) at (0,0); % intersection with coordinate axis
            \coordinate (C) at (-2,0);        
    % Dessin de l'arc de cercle entre CO et l'asymptote
    \draw[stealth-stealth, color=black, line width = 0.4pt]
        let \p1=($(O)-(C)$),\n1={veclen(\x1,\y1)} in
        (O) ++(135: \n1) arc (135:180: \n1) node[pos=0.5, above left] {$\alpha$};
    % asymptotes
    \draw [color=black!40, line width = 0.4pt, rotate around={45: (center)}]
        ($ (0, 0) + (center) $) --++(0.75*\lengthofasymptote, 0) ;
    \draw [color=black!40, line width = 0.4pt, rotate around={ 135: (center)}]
        ($ (0, 0) + (center) $) -- ++(0.75*\lengthofasymptote, 0) ;
    \end{tikzpicture}
    \caption*{Image 2}
    \vspace{1em} % Ajoutez de l'espace vertical si nécessaire
  \end{minipage} % Fin de la deuxième colonne
  \caption{Légende générale pour les deux figures}
  \label{fig:exemple_figures_alignees}
\end{figure}

給予:

在此輸入影像描述

答案1

右邊的圖比分配的空間寬。

如果我添加,為了顯示邊界框,

\usepackage[pass,showframe]{geometry}
\setlength{\fboxsep}{-\fboxrule}

到文檔序言並將兩個minipages 括在裡面\fbox{...},我得到

在此輸入影像描述

您會看到繪圖失敗minipage,甚至會收到警告:

Overfull \hbox (33.35834pt too wide) in paragraph at lines 91--91

(行號可能不同)。

當然,這取決於文件​​中的文字寬度。在標準文字寬度下,如果需要比例 0.45 : 0.5,則需要縮小其中一部分或兩部分。

將繪圖縮小到 0.35,而不是程式碼中的 0.45,似乎相當令人滿意:

在此輸入影像描述

我使用了\begin{minipage}[b]兩者,而不是[t],因此兩個圖例非常一致。\caption*順便說一句,不需要。

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{pgfplots}
\usepackage{pgf, tikz, adjustbox}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{angles,calc}
\usetikzlibrary{spy}
\usetikzlibrary{patterns, matrix, positioning}
\usetikzlibrary{decorations.markings, decorations.pathreplacing, arrows.meta,
                patterns.meta,
                quotes}
\usetikzlibrary{shapes.geometric}

 %%HYPERBOLE   
\newcommand\tikzhyperbola[6][thick]{%
  \draw [#1, rotate around={#2: (0, 0)}, shift=#3]
    plot [variable = \t, samples=1000, domain=-#6:#6] ({#4 / cos( \t )}, {#5 * tan( \t )});
}

\begin{document}

\begin{figure}[htp]
  \centering
  \begin{minipage}[b]{0.45\textwidth} % Définition de la taille de la première colonne
    \centering
    \includegraphics[width=\linewidth]{example-image}
    \caption*{Image 1}
  \end{minipage}% Fin de la première colonne
  \hfill % Espace horizontal entre les deux colonnes
  \begin{minipage}[b]{0.5\textwidth} % Définition de la taille de la deuxième colonne
    \centering
    \begin{tikzpicture}[
      scale=0.35,% <--- CHANGED HERE
      the_angle/.style args = {#1/#2}{
        draw,
        latex-latex,
        angle radius=#1,
        angle eccentricity=#2,
      }, % angle label position
      elli/.style args={#1:#2and#3}{
        draw,
        shape=ellipse,
        rotate=#1,
        minimum width=2*#2,
        minimum height=2*#3,
        outer sep=0pt,
      },
    ]
    \def\angle{90}
    \def\bigaxis{1.5cm}
    \def\smallaxis{1.5cm}
    \def\bigaxisbis{2.9cm}
    \def\smallaxisbis{3.6cm}
    
    \pgfmathsetmacro\axisratio{\smallaxis / \bigaxis}
    
    \coordinate (center) at (0, 0);
    
    \node [scale=0.55, elli=\angle:\bigaxis and \smallaxis, line width = 1.2pt, color=black, dotted] at (center) (e) {};
    
    \draw [-{stealth}, line width = 0.8pt, color = black] ([shift={(\angle:0)}] e.center) -- ([shift={(\angle:8)}] e.center) node [above right] {$z$};
    \draw [-{stealth}, line width = 1pt, color = black] ([shift={(0:-8)}] e.center) -- ([shift={(0:8)}] e.center) node [above left]  {$x$}  ;
    
    \draw[blue!80!black, very thick, Stealth-Stealth] (\bigaxis,0) --node[fill=white,scale = .65,right,xshift = 0.1 cm]{$h_{0}(t)$} (\bigaxis,\smallaxis);
    \draw[blue!80!black, dashed, thin] (0,\smallaxis) -- (\bigaxis,\smallaxis);
    \draw[red!80!black, very thick, Stealth-Stealth] (\bigaxisbis,0) --node[fill=white,scale = .65,right,xshift = 0.1 cm]{$h_{0}(t+\delta t)$} (\bigaxisbis,2.95cm);
    \draw[red!80!black, dashed, thin] (0,2.875cm) -- (3cm,2.95cm);
     % Dessin des 2 hyperboles
    \tikzhyperbola[line width = 1.2pt, color=blue!80!black]{\angle}{(center)}{\bigaxis}{\smallaxis}{77}
    \tikzhyperbola[line width = 1.2pt, color=red!80!black]{\angle}{(center)}{\bigaxisbis}{\smallaxisbis}{62}
    % asymptotes
    \def\lengthofasymptote{15}
            \coordinate (O) at (0,0); % intersection with coordinate axis
            \coordinate (C) at (-2,0);        
    % Dessin de l'arc de cercle entre CO et l'asymptote
    \draw[stealth-stealth, color=black, line width = 0.4pt]
        let \p1=($(O)-(C)$),\n1={veclen(\x1,\y1)} in
        (O) ++(135: \n1) arc (135:180: \n1) node[pos=0.5, above left] {$\alpha$};
    % asymptotes
    \draw [color=black!40, line width = 0.4pt, rotate around={45: (center)}]
        ($ (0, 0) + (center) $) --++(0.75*\lengthofasymptote, 0) ;
    \draw [color=black!40, line width = 0.4pt, rotate around={ 135: (center)}]
        ($ (0, 0) + (center) $) -- ++(0.75*\lengthofasymptote, 0) ;
    \end{tikzpicture}
    \caption*{Image 2}
  \end{minipage} % Fin de la deuxième colonne

\caption{Légende générale pour les deux figures}
\label{fig:exemple_figures_alignees}

\end{figure}

\end{document}

在此輸入影像描述

在這種情況下,提高影像似乎不太正確,但這取決於實際圖片的比例。

用肉眼衡量一下。和

  \begin{minipage}[b]{0.45\textwidth} % Définition de la taille de la première colonne
    \centering
    \includegraphics[width=\linewidth]{example-image}

    \vspace{5ex}

    \caption*{Image 1}
  \end{minipage}% Fin de la première colonne

對於圖片,輸出是

在此輸入影像描述

相關內容