1

About minimal thing developed originally mostly by Gonzalo Medina in earlier discussions of mine (one of them here)

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

It looks like

enter image description here

which I would like to change to look more like a discussion: same bolding to questions and green decoration etc, put on left hand side; simple text for answers, put on right-hand-side. I am open to any other suggestions for improvements.

My pseudocode

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

which includes now three questions in one environment. NB there is no textbf here anymore - only three questions! I am not sure how flexible this mdframed is to change to this.

The environment can be surrounded by any way, you want. The questions should be clearly visualised at the left hand hand side for instance. Their answers next to them. I would like to give the subquestions the same value as the first questions. At the moment, there is a hierarchy.

How can you make the mdframed environment more flexible with many questions?

  • 1
    which I would like to change to look more like a discussion -- What does this mean? – user31729 Oct 13 '14 at 16:49
  • @ChristianHupfer I added my explanation to the body. Give same decoration to questions marked by braces "{...}". Put their answers to the right-hand side of the questions. I am open to other suggestions for improvements. – Léo Léopold Hertz 준영 Oct 13 '14 at 16:57
3

Below I have defined the Question environment which uses a minipage for each comoponent and then the question and answer are placed in their own mdframed boxes:

enter image description here

If you want something like the iOS bubbles you can use the QuestionIOS environment defined below:

enter image description here


When you have a series of questions they should be specified in their own QuestionIOS environment:

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

which yields:

enter image description here

An alternate is QuestionIOSAlt environment within which you can use \newQuestionAlt to define a new question which is closer to your pseudocode. This yields results identical to what is shown above.

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

Note:

  • No changes are required to how you specify the info. Just using a different environment changes the style of the output.
  • If you don't want the questions in bold, remove the \bfseries in the environment definitions.

Code:

\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}
  • This good alternative! What about this: put all questions to the left and their corresponding answers to right - like iOS message system with bubles. – Léo Léopold Hertz 준영 Oct 13 '14 at 18:26
  • 1
    @Masi: See updated answer. Is that what you meant? – Peter Grill Oct 13 '14 at 18:46
  • It is good and almost. I mean to have those two other questions also at the left-hand-side as green bubbles, while their answers at the right-hand-side. Note that there is no textbf in my pseudocode. So questions are marked by braces {..} anywhere in the environment. – Léo Léopold Hertz 준영 Oct 13 '14 at 19:20
  • 1
    @Masi: Perhaps I am not fully understanding your question. If you have more than one question, each one gets its own environment. You proposed usage as shown in the pseudocode in the question is not the LaTeX way. It can probably be done, but I would not recommend that approach. It is much easier if you do it as shown in the updated answer. – Peter Grill Oct 13 '14 at 19:35
  • 1
    You still need someway to mark a new question. I have again revised the answer -- this time there is the `` environment within which you can mark the start of a new question with ``. Hopefully this addresses your question. Otherwise, please edit the question and clarify further. – Peter Grill Oct 13 '14 at 20:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.