零件环境中的 TikZ 图形

零件环境中的 TikZ 图形

我想在parts- 环境中显示 TikZ 图形,但图形出现在 (a) 部分上方而不是下方。我怎样才能让图片跟随 (a)?感谢您的帮助!

\documentclass[addpoints,12pt]{exam}

\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{amsmath, amssymb, amsmath}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\usepackage{siunitx}

\begin{document}

\begin{questions}
    \question
        Find $x\in \mathbb{Q}$.
        \begin{parts}
            \part 
                \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
                        \clip(-2.0992637227845954,-1.7878880377249167) rectangle (7.801609010358657,5.493825659968799);
                       \draw [domain=-2.0992637227845954:7.801609010358657] plot(\x,{(--6.6108--1.8599999999999999*\x)/3.96});
                       \draw [domain=-2.0992637227845954:7.801609010358657] plot(\x,{(--3.4032-0.72*\x)/4.2});
                       \draw [domain=-2.0992637227845954:7.801609010358657] plot(\x,{(--7.455599999999999-2.58*\x)/0.23999999999999977});
                       \draw (2.75,1.5) node {\rotatebox{60}{$\parallel$}};
                       \draw [domain=-2.0992637227845954:7.801609010358657] plot(\x,{(--13.01549181869475-2.58*\x)/0.23999999999999977});
                       \draw (4.85,1.8) node {\rotatebox{60}{$\parallel$}};
                       \draw (3,3.15) node[anchor=north west] {$\SI{1.5}{cm}$};
                       \draw (5.114713103302678,2.140850515449367) node[anchor=north west] {$x$};
                       \draw (0.28281626204234456,1.9263504220289323) node[anchor=north west] {$\SI{3}{cm}$};
                   \end{tikzpicture}
               \part
        \end{parts} 
\end{questions}

\end{document}

这是一张图片:

在此处输入图片描述

答案1

您可以添加baseline=(current bounding box.north)到的选项中tikzpicture

\documentclass[addpoints,12pt]{exam}

\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{amsmath, amssymb, amsmath}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\usepackage{siunitx}

\begin{document}

\begin{questions}
    \question
        Find $x\in \mathbb{Q}$.
        \begin{parts}
            \part 
                \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm,baseline=(current bounding box.north)]
                        \clip(-2.0992637227845954,-1.7878880377249167) rectangle (7.801609010358657,5.493825659968799);
                       \draw [domain=-2.0992637227845954:7.801609010358657] plot(\x,{(--6.6108--1.8599999999999999*\x)/3.96});
                       \draw [domain=-2.0992637227845954:7.801609010358657] plot(\x,{(--3.4032-0.72*\x)/4.2});
                       \draw [domain=-2.0992637227845954:7.801609010358657] plot(\x,{(--7.455599999999999-2.58*\x)/0.23999999999999977});
                       \draw (2.75,1.5) node {\rotatebox{60}{$\parallel$}};
                       \draw [domain=-2.0992637227845954:7.801609010358657] plot(\x,{(--13.01549181869475-2.58*\x)/0.23999999999999977});
                       \draw (4.85,1.8) node {\rotatebox{60}{$\parallel$}};
                       \draw (3,3.15) node[anchor=north west] {$\SI{1.5}{cm}$};
                       \draw (5.114713103302678,2.140850515449367) node[anchor=north west] {$x$};
                       \draw (0.28281626204234456,1.9263504220289323) node[anchor=north west] {$\SI{3}{cm}$};
                   \end{tikzpicture}
               \part
        \end{parts} 
\end{questions}

\end{document}

在此处输入图片描述

答案2

\raisebox{-\height}{<content>}将其内容移动到当前基线之下。

\documentclass[addpoints,12pt]{exam}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{amsmath, amssymb, amsmath}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\usepackage{siunitx}

\begin{document}

\begin{questions}
    \question
        Find $x\in \mathbb{Q}$.
  \begin{parts}
    \part
      \raisebox{-\height}{%
        \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
         \clip(-2.0992637227845954,-1.7878880377249167) rectangle (7.801609010358657,5.493825659968799);
         \draw [domain=-2.0992637227845954:7.801609010358657] plot(\x,{(--6.6108--1.8599999999999999*\x)/3.96});
         \draw [domain=-2.0992637227845954:7.801609010358657] plot(\x,{(--3.4032-0.72*\x)/4.2});
         \draw [domain=-2.0992637227845954:7.801609010358657] plot(\x,{(--7.455599999999999-2.58*\x)/0.23999999999999977});
         \draw (2.75,1.5) node {\rotatebox{60}{$\parallel$}};
         \draw [domain=-2.0992637227845954:7.801609010358657] plot(\x,{(--13.01549181869475-2.58*\x)/0.23999999999999977});
         \draw (4.85,1.8) node {\rotatebox{60}{$\parallel$}};
         \draw (3,3.15) node[anchor=north west] {$\SI{1.5}{cm}$};
         \draw (5.114713103302678,2.140850515449367) node[anchor=north west] {$x$};
         \draw (0.28281626204234456,1.9263504220289323) node[anchor=north west] {$\SI{3}{cm}$};
        \end{tikzpicture}%
      } 
    \part
  \end{parts} 
\end{questions}

\end{document}

在此处输入图片描述

答案3

图片与其底部(基线)对齐。\savebox 用于计算图片的高度,以便将其降低到 a 部分以下。

\documentclass[addpoints,12pt]{exam}

\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{amsmath, amssymb, amsmath}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{siunitx}
\usepackage{graphics,mwe}% for image

\newsavebox{\hold}
\newlength{\holdht}
\newcommand{\lowerit}[1]{% #1 = picture
\savebox{\hold}{#1}%
\settoheight{\holdht}{\usebox{\hold}}%
\raisebox{-\holdht}{\usebox{\hold}}%
}

\begin{document}

\begin{questions}
    \question
        Find $x\in \mathbb{Q}$.
        \begin{parts}
            \part
            \lowerit{
                \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
                \clip(-2.0992637227845954,-1.7878880377249167) rectangle (7.801609010358657,5.493825659968799);
                \draw [domain=-2.0992637227845954:7.801609010358657] plot(\x,{(--6.6108--1.8599999999999999*\x)/3.96});
                \draw [domain=-2.0992637227845954:7.801609010358657] plot(\x,{(--3.4032-0.72*\x)/4.2});
                \draw [domain=-2.0992637227845954:7.801609010358657] plot(\x,{(--7.455599999999999-2.58*\x)/0.23999999999999977});
                \draw (2.75,1.5) node {\rotatebox{60}{$\parallel$}};
                \draw [domain=-2.0992637227845954:7.801609010358657] plot(\x,{(--13.01549181869475-2.58*\x)/0.23999999999999977});
                \draw (4.85,1.8) node {\rotatebox{60}{$\parallel$}};
                \draw (3,3.15) node[anchor=north west] {$\SI{1.5}{cm}$};
                \draw (5.114713103302678,2.140850515449367) node[anchor=north west] {$x$};
                \draw (0.28281626204234456,1.9263504220289323) node[anchor=north west] {$\SI{3}{cm}$};
                \end{tikzpicture}
              }
           \part
             \lowerit{
               \includegraphics{image}
             }
       \end{parts}
\end{questions}

\end{document}

考試班

相关内容