Rexams working with \\tdplotsetmaincoords
02:52 22 Jun 2026

I can’t use the option \\tdplotsetmaincoords when plotting TikZ figures inside my Rnw file that then I pass to exams2moodle. Is there anything I’m missing on how to use the tikz-3dplot library?

Here is my MWE, the problematic lines are the first two lines in the definition of the tz variable

<>=



tz <- "
\\tdplotsetmaincoords{70}{125}
\\tikzset{tdplot_main_coords,line cap=round,>=stealth}
\\draw[->] (-5,0,0) -- (5,0,0) node[pos=1.05] {$x$};
\\draw[->] (0,-5,0) -- (0,5,0) node[pos=1.05] {$y$};
\\draw[->] (0,0,-4) -- (0,0,4) node[pos=1.05] {$z$};
%
\\draw plot[variable=\\t,domain=-4:4,samples=101,smooth]
({\\t},{sin(\\t*150)},{2*cos(\\t*150)});
"

## QUESTION/SOLUTION

nsol <- 9
questions <- solutions <- explanations <- points <- type <- rep(list(""), nsol)

points[] <- c(1, 1, 4,  4, 4, 1,  4, 4, 1) 

explanations[] <- solutions[] <- 1

tol <- num_to_tol(unlist(solutions), reltol = 0.01, min = 0.01, digits = 2)

explanations[] <- solutions[] <- round(unlist(solutions), 2)

type[] <- rep("num", nsol)
@    

\begin{question}


    
    

<>=
include_tikz(tz, name = "A",
format = match_exams_device(), width = "16cm", library = tikz_libraries)
@
    

\begin{center}
    $($ ##ANSWER1## $,$ ##ANSWER2## $,$ ##ANSWER3## $)$ \\
        
    $($ ##ANSWER4## $,$ ##ANSWER5## $,$ ##ANSWER6## $)$ \\

    $($ ##ANSWER7## $,$ ##ANSWER8## $,$ ##ANSWER9## $)$
\end{center}
    


<>=
answerlist(unlist(questions))
@ 


\end{question}


\begin{solution}


\end{solution}


%% META-INFORMATION
%% \exname{TT}
%% \exsection{TT}
%% \extitle{TT}
%% \exversion{0.2}
%% \extype{cloze}
%% \exclozetype{\Sexpr{paste(type, collapse = "|")}}
%% \expoints{\Sexpr{paste(points, collapse = "|")}}
%% \exsolution{\Sexpr{paste(solutions, collapse = "|")}}
%% \extol{\Sexpr{paste(tol, collapse = "|")}}
%% \exextra[numwidth,logical]{TRUE}

Thanks in advance

tikz r-exams