如何使用考试类将图片放到多个备选方案中?

如何使用考试类将图片放到多个备选方案中?

我想使用考试类将图片放在多项选择题的旁边,但我只能将其放在选项的上方或下方。这是我的代码:

\documentclass[12pt,a4paper,addpoints]{exam}
\renewcommand{\figurename}{Figura}
\renewcommand{\tablename}{Tabla}
\renewcommand{\thechoice}{\alph{choice}}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[a4paper]{geometry}
\usepackage{amsmath}
\usepackage{relsize}
\usepackage{wrapfig}
%\geometry{top=1.5cm, bottom=1.0cm, left=1.25cm, right=1.25cm}
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc,arrows,shapes,decorations.pathreplacing, positioning}
\usepackage{tcolorbox}
\tcbuselibrary{theorems,skins,raster}

\usepackage{hyphenat}
\hyphenation{des-pido desarro-llando adi-cio-nales extraor-dina-rias re-gular}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.9}
%\usepgfplotslibrary{external}
%\tikzexternalize
%\topmargin -2cm
\title{Ángulos y triángulos}
\author{Ejercicios de alternativas}
\date{Julio 2022}
%\renewcommand*\contentsname{Índice}
%\usepackage{fancyhdr}

%\pagestyle{fancy}
%\fancyhf{}
\rhead{Ángulos y triángulos}
\lhead{Ejercicios}
%\rfoot{Página \thepage}

\begin{document}

\maketitle
\tableofcontents

\vspace{2cm}

\begin{questions}
    \question
    En la figura, $\angle COA$ es recto. ¿Cuál es la medida del $\angle BOA$ ?

    \begin{choices}
        \choice 18$^0$
        \choice 32$^0$
        \choice 36$^0$
        \choice 54$^0$
        \choice 58$^0$
    \end{choices}

\begin{figure}[h]  
\centering 

\begin{tikzpicture}   
      \draw[->] (-0.5,0) -- (4,0) node[right] {$x$};  
      \draw[->] (0,-0.5) -- (0,4) node[above] {$y$};  
\end{tikzpicture}
\end{figure} 
\end{questions}
\end{document}

答案1

您可以使用该库并在最后一个选项旁边tikzmark添加标记。\tikzmark{<unique name>}

绘制图形,从起点添加适当的 x 偏移(本例中为 10 毫米)。原点位于右下角。(见小方块)

tikzmark库使用pic坐标系,因此使用 来调用标记pic cs: name。例如(pic cs:e)

该库calc允许符号+(< xshift >, < yshift >)引用原点的某个点。

A

\documentclass[12pt,a4paper,addpoints]{exam}
\renewcommand{\figurename}{Figura}
\renewcommand{\tablename}{Tabla}
\renewcommand{\thechoice}{\alph{choice}}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[a4paper]{geometry}
\usepackage{amsmath}
\usepackage{relsize}
\usepackage{wrapfig}
%\geometry{top=1.5cm, bottom=1.0cm, left=1.25cm, right=1.25cm}
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc,arrows,shapes,decorations.pathreplacing, positioning}
\usepackage{tcolorbox}
\tcbuselibrary{theorems,skins,raster}

\usepackage{hyphenat}
\hyphenation{des-pido desarro-llando adi-cio-nales extraor-dina-rias re-gular}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.9}
%\usepgfplotslibrary{external}
%\tikzexternalize
%\topmargin -2cm
\title{Ángulos y triángulos}
\author{Ejercicios de alternativas}
\date{Julio 2022}
%\renewcommand*\contentsname{Índice}
%\usepackage{fancyhdr}

%\pagestyle{fancy}
%\fancyhf{}
\rhead{Ángulos y triángulos}
\lhead{Ejercicios}
%\rfoot{Página \thepage}

\usetikzlibrary{tikzmark} % needed <<<<<<<<<<

\begin{document}
    
    \maketitle
    \tableofcontents
    
    \vspace{2cm}
    
    \begin{questions}
        \question
        En la figura, $\angle COA$ es recto. ¿Cuál es la medida del $\angle BOA$ ?
        \begin{choices}
            \choice 18$^0$
            \choice 32$^0$
            \choice 36$^0$
            \choice 54$^0$
            \choice 58$^0$\tikzmark{e}% mark added <<<<<<<<<<<
        \end{choices}
    
    \begin{tikzpicture}[overlay,remember picture]
        \draw ( $ (pic cs:e) +(0mm,0mm) $ ) rectangle ++(0.3,0.3); % show the origin
        \draw[->] ( $ (pic cs:e) +(10mm,0mm) $) -- ( $ (pic cs:e) +(35mm,0mm) $) node[right] {$x$};  
        \draw[->] ( $ (pic cs:e) +(10mm,0mm) $) -- ( $ (pic cs:e) +(10mm,25mm) $) node[above] {$y$}; 
     \end{tikzpicture}  

    \end{questions}

\end{document}

通过在标记的适当位置定义一个节点“Origin”,可以简化代码。

\begin{tikzpicture}[overlay,remember picture]
        \node (Origin) at ( $ (pic cs:e) +(0mm,5mm) $) {};
        \node (A) [right=of Origin] {A};
        \node (C) [right=of A]  {C};
        \node (B) [above=of C] {B};
        \draw[orange, ultra thick] (A.north) -- (C.north);
        \draw[orange, ultra thick] (A.north) -- (B.south);
        \draw[orange, ultra thick] (C.north) -- (B.south);
 \end{tikzpicture}

b

相关内容