El examen mantiene el espacio de la respuesta en blanco.

El examen mantiene el espacio de la respuesta en blanco.

Hago una plantilla de examen, el examen contiene las preguntas y respuestas, se define un conmutador para mostrar respuestas activadas o desactivadas. da todo cuando el conmutador está activado; de lo contrario, solo las preguntas con el espacio de respuesta dejado para escribir respuestas.

el paquetecaja de coloresse utiliza para diseñar el lugar de respuesta. el paquetehiperreferenciaA veces también se utiliza para hacer referencia al número de la pregunta.

Pero es posible que algo salga mal, las respuestas no pueden ser "blancas" (ocultas) y la referencia automática con enlace tampoco se puede ocultar cuando se usa el estilo del teorema amsmath en lugar de tcolorbox.

el MWE está debajo.

    \documentclass{article}

    \usepackage{lipsum}
    \def\exampleboxedtext{
         convenient way to generate a new theorem type. On the other hand, it enforces to use a titled
        \begin{equation}x^2 +y^2 =1\end{equation}
        a convenient way to generate a new theorem type. On the other hand, it
    }

    \usepackage[most]{tcolorbox}
    %------------------------
    \newcommand{\drtitt}{ %
        \node[anchor=north east,
        inner xsep=0pt,xshift=0.8em, %yshift=-0.2em,
        font=\bfseries] at (frame.north west) (tit) {\strut \fbox{ans}};
    }
    \newcommand{\drawTCBtopl}{
        \draw[line width=1.5pt,blue]([xshift=-2em,yshift=-0.2em]frame.north west)--([yshift=-0.2em]frame.north east); %top line
        }
    \newcommand{\drawTCBbotl}{
        \draw[line width=1.5pt,blue]([xshift=1.5em,yshift=0.3em]frame.south west)--([yshift=0.3em]frame.south east);
    }
    \newtcolorbox{examsolv}{ %
        empty,breakable,
        beforeafter skip=0pt,
        leftright skip=0pt,
        width=\dimexpr\linewidth+28pt\relax,
        text width=\linewidth-1mm,
        enlarge left by=-12pt,
        overlay unbroken ={\drtitt;\drawTCBtopl;\drawTCBbotl},
        overlay first={\drtitt; \drawTCBtopl},
        overlay middle={},
        overlay last={\drawTCBbotl},
        frame code={},interior code={},
        top=0pt,bottom=0pt,right=0pt
    }

    \newtoggle{showans} %etoolbox
    \togglefalse{showans}

    \newcommand{\yesnoans}[1]{\iftoggle{showans}{#1}{\color{white} #1}}
    \newenvironment{ansonoff}[1][0em]{ %
        \yesnoans
        \begingroup\begin{examsolv} %
        }{\end{examsolv} %
        \endgroup%
    }

    \usepackage{hyperref}

    \begin{document}

    \section{test}\label{sc:testsc}

    Switcher "showans" is off, but only the side text is hidden, the body still is showed. 

    \begin{ansonoff}
    \exampleboxedtext 
    that the ref with link like this \autoref{sc:testsc} cannot be hidden.
    this is a new problem! the typing text also cannot be hidden.
    \end{ansonoff}

    \lipsum[66]

    \begin{examsolv}
    \lipsum[66]
    \end{examsolv}

    \lipsum[66]

    \begin{enumerate}
    \item \lipsum[66]
    \begin{ansonoff}
        \lipsum[66-70]
    \end{ansonoff}
    \item \lipsum[66]
    \end{enumerate}

    \lipsum[66]
    \end{document}

Respuesta1

Ocultas la parte de la respuesta estableciendo el color en blanco, pero la configuración del color de a tcolorboxdebe especificarse, por ejemplo, mediante colupper. Tenga en cuenta que esto no influye en el color del marco del enlace:

\documentclass{article}

\usepackage{lipsum}
\def\exampleboxedtext{
     convenient way to generate a new theorem type. On the other hand, it enforces to use a titled
    \begin{equation}x^2 +y^2 =1\end{equation}
    a convenient way to generate a new theorem type. On the other hand, it
}

\usepackage[most]{tcolorbox}
%------------------------
\newcommand{\drtitt}{ %
    \node[anchor=north east,
    inner xsep=0pt,xshift=0.8em, %yshift=-0.2em,
    font=\bfseries] at (frame.north west) (tit) {\strut \fbox{ans}};
}
\newcommand{\drawTCBtopl}{
    \draw[line width=1.5pt,blue]([xshift=-2em,yshift=-0.2em]frame.north west)--([yshift=-0.2em]frame.north east); %top line
    }
\newcommand{\drawTCBbotl}{
    \draw[line width=1.5pt,blue]([xshift=1.5em,yshift=0.3em]frame.south west)--([yshift=0.3em]frame.south east);
}
\newtcolorbox{examsolv}{%
    empty,breakable,
    beforeafter skip=0pt,
    leftright skip=0pt,
    width=\dimexpr\linewidth+28pt\relax,
    text width=\linewidth-1mm,
    enlarge left by=-12pt,
    overlay unbroken ={\drtitt;\drawTCBtopl;\drawTCBbotl},
    overlay first={\drtitt; \drawTCBtopl},
    overlay middle={},
    overlay last={\drawTCBbotl},
    frame code={},interior code={},
    top=0pt,bottom=0pt,right=0pt
}

\newtoggle{showans} %etoolbox
\togglefalse{showans}

\newcommand{\yesnoans}[1]{\iftoggle{showans}{#1}{\color{white} #1}}

\newenvironment{ansonoff}{%
  \iftoggle{showans}{}{\color{white}\tcbset{colupper=white}}% <------------ Edited 
  \begin{examsolv}%
  }{\end{examsolv}%
}

\usepackage{hyperref}

\begin{document}

\section{test}\label{sc:testsc}

Switcher "showans" is off, but only the side text is hidden, the body still is showed.

\begin{ansonoff}
\exampleboxedtext
that the ref with link like this \autoref{sc:testsc} cannot be hidden.
this is a new problem! the typing text also cannot be hidden.
\end{ansonoff}

\lipsum[66]

\begin{examsolv}
\lipsum[66]
\end{examsolv}

\lipsum[66]

\begin{enumerate}
\item \lipsum[66]
\begin{ansonoff}
    \lipsum[66-70]
\end{ansonoff}
\item \lipsum[66]
\end{enumerate}

\lipsum[66]
\end{document}

ingrese la descripción de la imagen aquí

Una alternativa a establecer el color en blanco es colocar el material en la parte inferior del archivo tcolorbox. La parte inferior se puede ocultar con lowerbox=invisible. Esto elimina el contenido completo:

\documentclass{article}

\usepackage{lipsum}
\def\exampleboxedtext{
     convenient way to generate a new theorem type. On the other hand, it enforces to use a titled
    \begin{equation}x^2 +y^2 =1\end{equation}
    a convenient way to generate a new theorem type. On the other hand, it
}

\usepackage[most]{tcolorbox}
%------------------------
\newcommand{\drtitt}{ %
    \node[anchor=north east,
    inner xsep=0pt,xshift=0.8em, %yshift=-0.2em,
    font=\bfseries] at (frame.north west) (tit) {\strut \fbox{ans}};
}
\newcommand{\drawTCBtopl}{
    \draw[line width=1.5pt,blue]([xshift=-2em,yshift=-0.2em]frame.north west)--([yshift=-0.2em]frame.north east); %top line
    }
\newcommand{\drawTCBbotl}{
    \draw[line width=1.5pt,blue]([xshift=1.5em,yshift=0.3em]frame.south west)--([yshift=0.3em]frame.south east);
}
\newtcolorbox{examsolv}{%
    empty,breakable,
    beforeafter skip=0pt,
    leftright skip=0pt,
    width=\dimexpr\linewidth+28pt\relax,
    text width=\linewidth-1mm,
    enlarge left by=-12pt,
    overlay unbroken ={\drtitt;\drawTCBtopl;\drawTCBbotl},
    overlay first={\drtitt; \drawTCBtopl},
    overlay middle={},
    overlay last={\drawTCBbotl},
    frame code={},interior code={},
    top=0pt,bottom=0pt,right=0pt,
    middle=0mm,% unorthodox, but boxsep has a positive value <------------ Edited 
}

\newtoggle{showans} %etoolbox
\togglefalse{showans}

\newcommand{\yesnoans}[1]{\iftoggle{showans}{#1}{\color{white} #1}}

\newenvironment{ansonoff}{%
  \iftoggle{showans}{}{\color{white}\tcbset{lowerbox=invisible}}% <------------ Edited 
  \begin{examsolv}\tcblower%
  }{\end{examsolv}%
}

\usepackage{hyperref}

\begin{document}

\section{test}\label{sc:testsc}

Switcher "showans" is off, but only the side text is hidden, the body still is showed.

\begin{ansonoff}
\exampleboxedtext
that the ref with link like this \autoref{sc:testsc} cannot be hidden.
this is a new problem! the typing text also cannot be hidden.
\end{ansonoff}

\lipsum[66]

\begin{examsolv}
\lipsum[66]
\end{examsolv}

\lipsum[66]

\begin{enumerate}
\item \lipsum[66]
\begin{ansonoff}
    \lipsum[66-70]
\end{ansonoff}
\item \lipsum[66]
\end{enumerate}

\lipsum[66]
\end{document}

ingrese la descripción de la imagen aquí

información relacionada