免費論壇 繁體 | 簡體
Sclub交友聊天~加入聊天室當版主
分享
返回列表 发帖

如何排版这四个选项,使之与图片对齐?

  1. \documentclass{article}
  2. \usepackage{tikz}
  3. \usetikzlibrary{datavisualization} %for graphs and pictures
  4. \usetikzlibrary{datavisualization.formats.functions} %for graphs and pictures
  5. \usepackage{subcaption}

  6. \begin{document}

  7. \begin{figure}
  8. \begin{subfigure}[t]{0.23\linewidth}
  9. \centering
  10. \begin{tikzpicture}[baseline,remember picture]
  11.     \datavisualization [
  12.         scientific axes,
  13.         x axis = {label={},length=2.0cm,include value={-0.5,1.5}},
  14.         y axis = {label={},length=2.0cm,include value={0.5,-1.5}},
  15.         visualize as smooth line=one,
  16.         one={style={red}}
  17.         ]
  18.     data [set=one, format=function] {
  19.     var x : interval [0:1];
  20.     func y = -\value x ;
  21.     };
  22. \end{tikzpicture}
  23. \end{subfigure}
  24. %
  25. \begin{subfigure}[t]{0.23\linewidth}
  26. \centering
  27. \begin{tikzpicture}[baseline,remember picture]
  28.     \datavisualization [
  29.         scientific axes,
  30.         x axis = {label={},length=2.0cm,include value={-0.5,1.5}},
  31.         y axis = {label={},length=2.0cm,include value={0.5,-1.5}},
  32.         visualize as smooth line=two,
  33.         two={style={orange}}
  34.         ]
  35.     data [set=two, format=function] {
  36.     var x : interval [0:1];
  37.     func y = -sqrt(\value x) ;
  38.     };
  39. \end{tikzpicture}
  40. \end{subfigure}
  41. %
  42. \begin{subfigure}[t]{0.23\linewidth}
  43. \centering
  44. \begin{tikzpicture}[baseline,remember picture]
  45.     \datavisualization [
  46.         scientific axes,
  47.         x axis = {label={},length=2.0cm,include value={-0.5,1.5}},
  48.         y axis = {label={},length=2.0cm,include value={0.5,-1.5}},
  49.         visualize as smooth line=three,
  50.         three={style={blue}}
  51.         ]
  52.     data [set=three, format=function] {
  53.     var x : interval [0:1];
  54.     func y = \value x * \value x -2*\value x;
  55.     };  
  56. \end{tikzpicture}
  57. \end{subfigure}
  58. %
  59. \begin{subfigure}[t]{0.23\linewidth}
  60. \centering
  61. \begin{tikzpicture}[baseline,remember picture]
  62.     \datavisualization [
  63.         scientific axes,
  64.         x axis = {label={},length=2.0cm,include value={-0.5,1.5}},
  65.         y axis = {label={},length=2.0cm,include value={0.5,-1.5}},
  66.         visualize as smooth line=three,
  67.         three={style={green}}
  68.         ]
  69.     data [set=three, format=function] {
  70.     var x : interval [0:1];
  71.     func y = -sqrt(2*\value x-\value x * \value x );
  72.     };  
  73. \end{tikzpicture}
  74. \end{subfigure}
  75. %
  76. \subcaptionbox{\(y=-x\) \label{fig:z}}[0.230\linewidth]{}%
  77. \subcaptionbox{\(y=-\sqrt{x}\) \label{fig:g}}[0.23\linewidth]{}%
  78. \subcaptionbox{\(y=x^2-2x\) \label{fig:p}}[0.23\linewidth]{}%
  79. \subcaptionbox{\(y=-\sqrt{2x-x^2}\) \label{fig:y}}[0.23\linewidth]{}%
  80. \caption{Caption for figure \label{fig:whole}}
  81. \end{figure}

  82. References to subfigures \subref{fig:z}, \subref{fig:g}, \subref{fig:p}, and \subref{fig:y} in Fig.~\ref{fig:whole}.
  83. \end{document}
复制代码
QQ截图20180318153509.png
2018-3-18 15:36
分享到: QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友

以下写法照搬自 subcaption 宏包手册第 4 页。

另外,[baseline,remember picture] 是多余的,我去掉了,而四个图放一起略显挤,所以我加了 [scale=0.9] 缩小一点点。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{datavisualization} %for graphs and pictures
\usetikzlibrary{datavisualization.formats.functions} %for graphs and pictures
\usepackage{subcaption}

\begin{document}

\begin{figure}
\begin{minipage}[b]{0.25\linewidth}
\centering
\begin{tikzpicture}[scale=0.9]
    \datavisualization [
        scientific axes,
        x axis = {label={},length=2.0cm,include value={-0.5,1.5}},
        y axis = {label={},length=2.0cm,include value={0.5,-1.5}},
        visualize as smooth line=one,
        one={style={red}}
        ]
    data [set=one, format=function] {
    var x : interval [0:1];
    func y = -\value x ;
    };
\end{tikzpicture}
\subcaption{\(y=-x\)}\label{fig:z}
\end{minipage}%←这个百分号请勿删除,下同
%
\begin{minipage}[b]{0.25\linewidth}
\centering
\begin{tikzpicture}[scale=0.9]
    \datavisualization [
        scientific axes,
        x axis = {label={},length=2.0cm,include value={-0.5,1.5}},
        y axis = {label={},length=2.0cm,include value={0.5,-1.5}},
        visualize as smooth line=two,
        two={style={orange}}
        ]
    data [set=two, format=function] {
    var x : interval [0:1];
    func y = -sqrt(\value x) ;
    };
\end{tikzpicture}
\subcaption{\(y=-\sqrt{x}\)}\label{fig:g}
\end{minipage}%
%
\begin{minipage}[b]{0.25\linewidth}
\centering
\begin{tikzpicture}[scale=0.9]
    \datavisualization [
        scientific axes,
        x axis = {label={},length=2.0cm,include value={-0.5,1.5}},
        y axis = {label={},length=2.0cm,include value={0.5,-1.5}},
        visualize as smooth line=three,
        three={style={blue}}
        ]
    data [set=three, format=function] {
    var x : interval [0:1];
    func y = \value x * \value x -2*\value x;
    };
\end{tikzpicture}
\subcaption{\(y=x^2-2x\)}\label{fig:p}
\end{minipage}%
%
\begin{minipage}[b]{0.25\linewidth}
\centering
\begin{tikzpicture}[scale=0.9]
    \datavisualization [
        scientific axes,
        x axis = {label={},length=2.0cm,include value={-0.5,1.5}},
        y axis = {label={},length=2.0cm,include value={0.5,-1.5}},
        visualize as smooth line=three,
        three={style={green}}
        ]
    data [set=three, format=function] {
    var x : interval [0:1];
    func y = -sqrt(2*\value x-\value x * \value x );
    };
\end{tikzpicture}
\subcaption{\(y=-\sqrt{2x-x^2}\)}\label{fig:y}
\end{minipage}
\caption{Caption for figure}\label{fig:whole}
\end{figure}

References to subfigures \subref{fig:z}, \subref{fig:g}, \subref{fig:p}, and \subref{fig:y} in Fig.~\ref{fig:whole}.
\end{document}
冇钱又冇样、冇型又冇款、冇身材又冇文采、冇学历又冇能力、冇高度冇速度冇力度兼夹冇野做!(粤语)
口号:珍爱生命,远离考试。

TOP

这处理这种图,都是直接把选项 弄成 node

TOP

返回列表 回复 发帖