¿Cómo sería posible tener el mismo espacio entre la figura y ambos márgenes de la página en este ejemplo?
Además, me gustaría ajustar el lado inferior de la figura izquierda con el eje x
de la imagen tikz derecha: ¿cómo hacerlo?
Gracias por su ayuda,
Atentamente,
Código:
\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}
EDITAR: Intenté implementar baseline
para alinear las figuras verticalmente pero cometí un error porque no funciona correctamente.
Código:
\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}
Donación :
Respuesta1
Su dibujo de la derecha es más ancho que el espacio asignado.
Si agrego, con el fin de mostrar los cuadros delimitadores,
\usepackage[pass,showframe]{geometry}
\setlength{\fboxsep}{-\fboxrule}
al preámbulo del documento y adjunto las dos minipage
s dentro \fbox{...}
, obtengo
Ves que el dibujo se sale minipage
y hasta te avisan de esto:
Overfull \hbox (33.35834pt too wide) in paragraph at lines 91--91
(Los números de línea pueden diferir).
Por supuesto, esto depende del ancho del texto que tengas en tu documento. Con el ancho de texto estándar, si necesita la proporción 0,45: 0,5, deberá reducir una o ambas partes.
Reducir la escala del dibujo a 0,35, en lugar de 0,45 como en el código, parece bastante satisfactorio:
Usé \begin{minipage}[b]
para ambos, en lugar de [t]
, por lo que las dos leyendas están bien alineadas. \caption*
Por cierto, no es necesario .
\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}
En este caso, elevar la imagen no parece correcto, pero depende de las proporciones de la imagen real.
Mídelo a ojo. Con
\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
para la imagen, la salida es