papel de exame mantém o espaço da resposta em branco

papel de exame mantém o espaço da resposta em branco

Eu faço um modelo de prova, o papel contém as perguntas e respostas, um switcher é definido para mostrar as respostas liga/desliga. dá tudo quando o switcher está ligado, caso contrário apenas as perguntas com a resposta deixando espaço para escrever as respostas.

o pacotecaixa de coresé usado para definir o estilo do local da resposta. o pacotehiperreftambém é usado para fazer referência ao número da pergunta às vezes.

Mas algo pode dar errado, as respostas não podem ser "brancas" (ocultas) e o autoref com link também não pode ser oculto ao usar o estilo do teorema amsmath em vez do tcolorbox.

o MWE está abaixo.

    \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}

Responder1

Você oculta a parte da resposta definindo a cor como branco, mas a configuração de cor de a tcolorboxdeve ser especificada por, por exemplo colupper, . Observe que isso não influencia a cor do quadro do link:

\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}

insira a descrição da imagem aqui

Uma alternativa para definir a cor para branco é colocar o material na parte inferior do arquivo tcolorbox. A parte inferior pode ser ocultada por lowerbox=invisible. Isso remove o conteúdo 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}

insira a descrição da imagem aqui

informação relacionada