So integrieren Sie eine Figur in den Latex-Hauptkörper

So integrieren Sie eine Figur in den Latex-Hauptkörper

Ich habe eine Abbildung wie diese, die zwei Unterabbildungen hat. Wie kann ich diese in mein anderes Hauptdokument einbinden? Wo kann ich \input{figure_name} verwenden und diese Abbildung wird in meinem übergeordneten Dokument angezeigt.

\documentclass{article}

\usepackage{subcaption}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{adjustbox}

\begin{document}


\begin{figure}
        \centering
        \begin{subfigure}[b]{0.4\textwidth}
            \begin{tikzpicture}
                \begin{axis}[
                    trig format=rad,    % <---
                    domain=0:1,         % <---
                    samples=501,        % <---
                    no marks]           % <---
                \addplot {sin(10*x};
                
                \legend{$\sin(10x)$}
                \end{axis}
                    \end{tikzpicture}
        \end{subfigure}
        \hfill
        \begin{subfigure}[b]{0.4\textwidth}
            \begin{tikzpicture}
                \begin{axis}[
                    trig format=rad,    % <---
                    domain=0:1,         % <---
                    samples=501,        % <---
                    no marks]           % <---
                \addplot {sin(100*x};
               
                \legend{$\sin(100x)$}
                \end{axis}
            \end{tikzpicture}
        \end{subfigure}
        \caption{Increasing oscillatory function}
\end{figure}
    
\end{document}

Antwort1

So was:

Bildbeschreibung hier eingeben

Ich gehe davon aus, dass beide Bilder die gleichen axisEinstellungen haben, daher kann man sie lokal schreiben \pgfplotssetund so den Bildcode etwas kürzer machen:

\documentclass{article}

\usepackage{subcaption}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}
    \begin{figure}
    \centering
\pgfplotsset{% common settings for both images
    width=\linewidth,
    scale only axis,
    trig format=rad,    % <---
    domain=0:pi/2,      % <---
    samples=501,        % <---
    no marks,           % <---
% added,˛
    every axis plot post/.append style={semithick},
    legend style={font=\footnotesize,
                  cells={anchor=west}}
            }

\begin{subfigure}[b]{0.45\textwidth}
    \begin{tikzpicture}
\begin{axis}
\addplot {sin(10*x};
\addplot {sin(25*x)};
\addplot {sin(50*x)};

\legend{$\sin(10x)$,$\sin(25x)$,$\sin(50x)$}
\end{axis}
    \end{tikzpicture}
\end{subfigure}
\hfil
\begin{subfigure}[b]{0.45\textwidth}
    \begin{tikzpicture}
\begin{axis}
\addplot {sin(100*x)};
\addplot {sin(150*x))};
\addplot {sin(200*x))};

\legend{$\sin(100x)$,$\sin(150x)$,$\sin(200x)$}
\end{axis}
    \end{tikzpicture}
\end{subfigure}
\caption{Increasing oscillatory function}
\label{fig:??}
    \end{figure}
\end{document}

Wie Sie sehen, sind die Bilder bei paralleler Darstellung bei diesem Seitenlayout deutlich schmaler und daher weniger übersichtlich. Um die Sichtbarkeit der Diagramme zu verbessern, haben Sie mehrere Möglichkeiten:

  • Seitenlayout ändern mit Vergrößern\textwidth
  • ein Bild über das andere legen
  • Domäne beim zweiten Bild reduzieren

Nachtrag:

  • Ich frage mich, warum Ihre Unterfiguren keine Bildunterschriften haben
  • Wenn sie nicht erwünscht sind, können Sie groupplotanstelle von verwendensubfigures
  • Im folgenden MWE wird Folgendes berücksichtigt:
    • Reduzierter Wellenbereich für zweite Bilder
    • erhöht \textwidthdurch Nutzung des geometryPakets
    • für Mengenangaben in Bildunterschriften wird das Paket „siunnitx“ verwendet.
\documentclass{article}
\usepackage{geometry}   % for setting page layout

\usepackage{siunitx}
\usepackage[font=small]{subcaption}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}
    \begin{figure}
\pgfplotsset{% common settings for both images
    width=0.8\linewidth,
    scale only axis,
    enlargelimits = 0.05,
    trig format=rad,     
    samples=801,         
    no marks,            
% added, for better diagram formating
    x tick label style={/pgf/number format/.cd, zerofill, fixed},
    every axis plot post/.append style={semithick},
    legend style={font=\footnotesize,
                  cells={anchor=west}}
            }

\begin{subfigure}[b]{0.48\textwidth}
    \begin{tikzpicture}
\begin{axis}[
        domain=0:1,      % <---
            ]
\addplot {sin(10*x};
\addplot {sin(25*x)};
\addplot {sin(50*x)};

\legend{$\sin(10x)$,$\sin(25x)$,$\sin(50x)$}
\end{axis}
    \end{tikzpicture}
\caption{Sinus waves on domain \qtyrange{0}{1}{\radian}.}
\end{subfigure}
\hfil
\begin{subfigure}[b]{0.48\textwidth}
    \begin{tikzpicture}
\begin{axis}[
        domain=0:0.25,      % <---
            ]
\addplot {sin(100*x)};
\addplot {sin(150*x)};
\addplot {sin(200*x)};

\legend{$\sin(100x)$,$\sin(150x)$,$\sin(200x)$}
\end{axis}
    \end{tikzpicture}
\caption{Sinus waves on domain \qtyrange{0}{0.25}{\radian}.}
\end{subfigure}
\caption{Increasing oscillatory function}
\label{fig:??}
    \end{figure}
\end{document}

Bildbeschreibung hier eingeben

\documentclass{article}
\usepackage{geometry}   % for setting page layout

\usepackage{siunitx}
\usepackage[font=small]{subcaption}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}
    \begin{figure}
\pgfplotsset{% common settings for both images
    width=0.8\linewidth,
    scale only axis,
    enlargelimits = 0.05,
    trig format=rad,    % <---
    samples=801,        % <---
    no marks,           % <---
% added,
    x tick label style={/pgf/number format/.cd, zerofill, fixed},
    every axis plot post/.append style={semithick},
    legend style={font=\footnotesize,
                  cells={anchor=west}}
            }

\begin{subfigure}[b]{0.48\textwidth}
    \begin{tikzpicture}
\begin{axis}[
        domain=0:1,      % <---
            ]
\addplot {sin(10*x};
\addplot {sin(25*x)};
\addplot {sin(50*x)};

\legend{$\sin(10x)$,$\sin(25x)$,$\sin(50x)$}
\end{axis}
    \end{tikzpicture}
\caption{Sinus waves on domain \qtyrange{0}{1}{\radian}.}
\end{subfigure}
\hfil
\begin{subfigure}[b]{0.48\textwidth}
    \begin{tikzpicture}
\begin{axis}[
        domain=0:0.25,      % <---
            ]
\addplot {sin(100*x)};
\addplot {sin(150*x)};
\addplot {sin(200*x)};

\legend{$\sin(100x)$,$\sin(150x)$,$\sin(200x)$}
\end{axis}
    \end{tikzpicture}
\caption{Sinus waves on domain \qtyrange{0}{0.25}{\radian}.}
\end{subfigure}
\caption{Increasing oscillatory function}
\label{fig:??}
    \end{figure}
\end{document}

verwandte Informationen