打造问题环境、讨论环境

打造问题环境、讨论环境

关于最初主要由开发的最小事物贡萨洛·梅迪纳在我之前的讨论中(其中一次这里

\documentclass{article}        
\usepackage[framemethod=tikz]{mdframed}

\mdfdefinestyle{ans}{
  linecolor=cyan,
  backgroundcolor=yellow!20,
    frametitlebackgroundcolor=green!40,
    frametitlerule=true
}
\newcounter{question}[section]%
\setcounter{question}{0}

\newenvironment{question}[1]{%
\refstepcounter{question}%
    \begin{mdframed}[style=ans,frametitle={Question: #1}]
}{%
    \end{mdframed}%

}%
\begin{document}


\begin{question}
{Main complaints of this patient with hepatitis?}
Muscle pain.
Jaundice is a typical symptom (nonspecific) but not pain. 
% Icterus is not a complain
Enlargement of the liver.  % hepatomegaly
\textbf{Why muscle pain is coming?} 
Virus infection. 
% There exists no specific symptom for viral hepatitis. 
Intoxication can be but it is untypical.
\textbf{What can you find in the blood analysis?} 
Increased liver enzymes (ALAT, ASAT). 
\end{question}

\end{document}

看起来像

在此处输入图片描述

我想将其改为更像讨论:问题和绿色装饰等同样加粗,放在左侧;答案的简单文本放在右侧。我愿意听取任何其他改进建议。

我的伪代码

\begin{question}
{Main complaints of this patient with hepatitis?}
Muscle pain.
Jaundice is a typical symptom (nonspecific) but not pain. 
% Icterus is not a complain
Enlargement of the liver.  % hepatomegaly
{Why muscle pain is coming?} 
Virus infection. 
% There exists no specific symptom for viral hepatitis. 
Intoxication can be but it is untypical.
{What can you find in the blood analysis?} 
Increased liver enzymes (ALAT, ASAT). 
\end{question}

其中包括一个环境中的三个问题。 注意:这里不再有textbf- 只有三个问题!我不确定mdframed改变这一点有多灵活。

可以以任何你想要的方式包围环境。例如,问题应该在左侧清晰可见。答案就在旁边。我想给子问题赋予与第一个问题相同的值。目前,有一个层次结构。

如何让 mdframed 环境更加灵活,解决诸多问题?

答案1

下面我定义了Question使用minipage每个组件的环境,然后将问题和答案放在各自的mdframed框中:

在此处输入图片描述

如果您想要类似 iOS 气泡的东西,您可以使用QuestionIOS下面定义的环境:

在此处输入图片描述


当你有一系列问题时,它们应该在自己的QuestionIOS环境中指定:

\begin{QuestionIOS}{Main complaints of this patient with hepatitis?}
    Muscle pain.
    Jaundice is a typical symptom (nonspecific) but not pain. 
    % Icterus is not a complain
    Enlargement of the liver.  % hepatomegaly
\end{QuestionIOS}
\begin{QuestionIOS}{Why muscle pain is coming?} 
    Virus infection. 
    % There exists no specific symptom for viral hepatitis. 
    Intoxication can be but it is untypical.
\end{QuestionIOS}
\begin{QuestionIOS}{What can you find in the blood analysis?} 
    Increased liver enzymes (ALAT, ASAT). 
\end{QuestionIOS}

得出的结果是:

在此处输入图片描述

另一种是QuestionIOSAlt环境,您可以在其中\newQuestionAlt定义更接近您的问题的新问题pseudocode。这会产生与上面显示的结果相同的结果。

\begin{QuestionIOSAlt}{Main complaints of this patient with hepatitis?}
        Muscle pain.
        Jaundice is a typical symptom (nonspecific) but not pain. 
        % Icterus is not a complain
        Enlargement of the liver.  % hepatomegaly
    \newQuestionAlt{Why muscle pain is coming?} 
        Virus infection. 
        % There exists no specific symptom for viral hepatitis. 
        Intoxication can be but it is untypical.
    \newQuestionAlt{What can you find in the blood analysis?} 
        Increased liver enzymes (ALAT, ASAT). 
\end{QuestionIOSAlt}

笔记:

  • 您指定信息的方式无需更改。只需使用不同的环境即可改变输出的样式。
  • 如果您不想要粗体问题,请删除\bfseries环境定义中的内容。

代码:

\documentclass{article}        
\usepackage[framemethod=tikz]{mdframed}

\mdfdefinestyle{ans}{
  linecolor=cyan,
  backgroundcolor=yellow!20,
}
\mdfdefinestyle{ques}{
  linecolor=cyan,
  backgroundcolor=green!20,
}

\newcounter{question}[section]%
\setcounter{question}{0}

\newenvironment{question}[1]{%
    \refstepcounter{question}%
    \begin{mdframed}[style=ans,frametitle={Question: #1}]
}{%
    \end{mdframed}%

}%

\newenvironment{Question}[1]{%
    \refstepcounter{question}%
    \noindent%
    \begin{minipage}{0.22\linewidth}
        \begin{mdframed}[style=ques]
            \bfseries\raggedright
            Question: #1
        \end{mdframed}%
    \end{minipage}%
    \hfill%
    \begin{minipage}{0.70\linewidth}
        \begin{mdframed}[style=ans]
}{%
    \end{mdframed}%
    \end{minipage}%
}%

\newenvironment{QuestionIOS}[1]{%
    \refstepcounter{question}%
    \smallskip\par%
    \noindent%
    \begin{minipage}{0.75\linewidth}
        \begin{mdframed}[style=ques, roundcorner=7.0pt, linewidth=1pt]
            \bfseries\raggedright
            Question: #1
        \end{mdframed}%
    \end{minipage}%
    \smallskip\par\hfill%
    \begin{minipage}{0.75\linewidth}
        \begin{mdframed}[style=ans, roundcorner=7.0pt, linewidth=1pt]
}{%
    \end{mdframed}%
    \end{minipage}%
}%

\newenvironment{QuestionIOSAlt}[1]{%
    \newcommand*{\newQuestionAlt}[1]{%
            \end{mdframed}%
            \end{minipage}%
            \refstepcounter{question}%
            \smallskip\par%
            \noindent%
            \begin{minipage}{0.75\linewidth}
            \begin{mdframed}[style=ques, roundcorner=7.0pt, linewidth=1pt]
                \bfseries\raggedright
                Question: ##1
            \end{mdframed}%
        \end{minipage}%
        \smallskip\par\hfill%
        \begin{minipage}{0.75\linewidth}
        \begin{mdframed}[style=ans, roundcorner=7.0pt, linewidth=1pt]
    }%
    \refstepcounter{question}%
    \smallskip\par%
    \noindent%
    \begin{minipage}{0.75\linewidth}
        \begin{mdframed}[style=ques, roundcorner=7.0pt, linewidth=1pt]
            \bfseries\raggedright
            Question: #1
        \end{mdframed}%
    \end{minipage}%
    \smallskip\par\hfill%
    \begin{minipage}{0.75\linewidth}
        \begin{mdframed}[style=ans, roundcorner=7.0pt, linewidth=1pt]
}{%
    \end{mdframed}%
    \end{minipage}%
}%


\newcommand*{\AnswerText}{%
Muscle pain.
Jaundice is a typical symptom (nonspecific) but not pain. 
% Icterus is not a complain
Enlargement of the liver.  % hepatomegaly
\textbf{Why muscle pain is coming?} 
Virus infection. 
% There exists no specific symptom for viral hepatitis. 
Intoxication can be but it is untypical.
\textbf{What can you find in the blood analysis?} 
Increased liver enzymes (ALAT, ASAT). 
}

\begin{document}

\noindent\verb|question| environment:\medskip\par
\begin{question}{Main complaints of this patient with hepatitis?}
\AnswerText
\end{question}

\bigskip\hrule\bigskip
\noindent\verb|Question| environment:\medskip\par
\begin{Question}{Main complaints of this patient with hepatitis?}
\AnswerText
\end{Question}

\bigskip\hrule\bigskip
\noindent\verb|QuestionIOS| environment:\medskip\par
\begin{QuestionIOS}{Main complaints of this patient with hepatitis?}
\AnswerText
\end{QuestionIOS}

\clearpage
\noindent\verb|QuestionIOS| environment with multiple questions:\medskip\par
\begin{QuestionIOS}{Main complaints of this patient with hepatitis?}
    Muscle pain.
    Jaundice is a typical symptom (nonspecific) but not pain. 
    % Icterus is not a complain
    Enlargement of the liver.  % hepatomegaly
\end{QuestionIOS}
\begin{QuestionIOS}{Why muscle pain is coming?} 
    Virus infection. 
    % There exists no specific symptom for viral hepatitis. 
    Intoxication can be but it is untypical.
\end{QuestionIOS}
\begin{QuestionIOS}{What can you find in the blood analysis?} 
    Increased liver enzymes (ALAT, ASAT). 
\end{QuestionIOS}

\bigskip\hrule\bigskip
\noindent\verb|QuestionIOSAlt| environment with multiple questions and \verb|\newQuestionAlt| to start a new question:\medskip\par
\begin{QuestionIOSAlt}{Main complaints of this patient with hepatitis?}
        Muscle pain.
        Jaundice is a typical symptom (nonspecific) but not pain. 
        % Icterus is not a complain
        Enlargement of the liver.  % hepatomegaly
    \newQuestionAlt{Why muscle pain is coming?} 
        Virus infection. 
        % There exists no specific symptom for viral hepatitis. 
        Intoxication can be but it is untypical.
    \newQuestionAlt{What can you find in the blood analysis?} 
        Increased liver enzymes (ALAT, ASAT). 
\end{QuestionIOSAlt}
\end{document}

相关内容