在此示例中,如何才能使图形和页面的两个边距之间具有相同的空间:
另外,我想用右 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}
到文档序言并将两个minipage
s 括在里面\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
对于图片,输出是