시험지는 답안 공간을 하얗게 유지한다

시험지는 답안 공간을 하얗게 유지한다

나는 시험지 템플릿을 만들고, 그 종이에는 질문과 답변이 포함되어 있으며, 답변을 표시/해제하기 위한 스위처가 정의되어 있습니다. 스위처가 켜져 있으면 모든 것을 제공하고, 그렇지 않으면 답변을 작성할 수 있는 답변 공간이 있는 질문만 제공합니다.

패키지티컬러박스답변 장소의 스타일을 지정하는 데 사용됩니다. 패키지하이퍼레프또한 때때로 질문의 번호를 참조하는 데 사용됩니다.

그러나 문제가 발생할 수 있으며, 답변은 "흰색"(숨김)일 수 없으며, tcolorbox 대신 amsmath 정리 스타일을 사용할 때 링크가 있는 자동 참조도 숨길 수 없습니다.

MWE는 아래와 같습니다.

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

답변1

색상을 흰색으로 설정하여 답변 부분을 숨기지만 a 의 색상 설정은 tcolorbox예를 들어 로 지정해야 합니다 colupper. 이는 링크의 프레임 색상에 영향을 미치지 않습니다.

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

여기에 이미지 설명을 입력하세요

색상을 흰색으로 설정하는 대신 항목을 tcolorbox. 하단 부분은 으로 숨길 수 있습니다 lowerbox=invisible. 이렇게 하면 전체 콘텐츠가 제거됩니다.

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

여기에 이미지 설명을 입력하세요

관련 정보