我有一個像這樣的數字,它有兩個子數字;如何將其包含在我的其他主文檔中?我可以在哪裡使用 \input{figure_name} 並且該圖顯示在我的父文檔中。
\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}
答案1
像這樣:
我假設兩個圖像具有相同的axis
設置,因此可以在本地寫入\pgfplotsset
,這樣可以使圖形代碼更短一些:
\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}
正如您所看到的,如果您有並行的圖像,它們在給定的頁面佈局中會相當窄,因此不太清晰。為了提高圖表的可見性,您有多種選擇:
- 透過放大更改頁面佈局
\textwidth
- 將一張圖片放在另一張圖片上方
- 縮小第二張影像的域
附錄:
- 我想知道為什麼你的子圖沒有標題
- 如果不需要它們,您可以考慮使用
groupplot
使用subfigures
- 在下面的 MWE 中,考慮:
- 第二張影像的縮減波域
\textwidth
透過使用增加geometry
包- 對於子圖標題中的數量,使用 ˙siunnitx` 包Č
\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}
\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}