See the last edit for automatic toggling
You can define a new environment Answer
based on your answer
environment:
\usepackage{environ}
\NewEnviron{Answer}
{%
\noindent
\rotatebox[origin=c]{180}{%
\noindent
\begin{minipage}[t]{\linewidth}
\begin{answer}
\BODY
\end{answer}%
\end{minipage}%
}%
}%
Full code:
\documentclass{article}
\usepackage{rotating}
\usepackage[framemethod=tikz]{mdframed}
\newtheorem{question}{Question}
\mdfdefinestyle{que}{
linecolor=cyan,
backgroundcolor=cyan!20,
}
\surroundwithmdframed[style=que]{question}
\newtheorem{answer}{Answer}
\mdfdefinestyle{ans}{
linecolor=cyan,
backgroundcolor=yellow!20
% , rotatebox
}
\surroundwithmdframed[style=ans]{answer}
\usepackage{environ}
\NewEnviron{Answer}
{%
\noindent
\rotatebox[origin=c]{180}{%
\noindent
\begin{minipage}[t]{\linewidth}
\begin{answer}
\BODY
\end{answer}%
\end{minipage}%
}%
}%
\begin{document}
\begin{question}
\textbf{E.coli.}
Escherichia coli ...
\end{question}
\begin{Answer}
Lorem ipsum is not an answer to this question but this text will provide some dummy answer for two lines all together.
\end{Answer}
\end{document}
Making it to difficult to read?. Here we go:
\documentclass{article}
\usepackage{rotating}
\usepackage[framemethod=tikz]{mdframed}
\newtheorem{question}{Question}
\mdfdefinestyle{que}{
linecolor=cyan,
backgroundcolor=cyan!20,
}
\surroundwithmdframed[style=que]{question}
\newtheorem{answer}{Answer}
\mdfdefinestyle{ans}{
linecolor=cyan,
backgroundcolor=yellow!20
% , rotatebox
}
\surroundwithmdframed[style=ans]{answer}
\usepackage{environ}
\NewEnviron{Answer}
{%
\noindent
\reflectbox{\rotatebox[origin=c]{180}{%
\noindent
\begin{minipage}[t]{\linewidth}
\begin{answer}
\BODY
\end{answer}%
\end{minipage}%
}%
}}%
\begin{document}
\begin{question}
\textbf{E.coli.}
Escherichia coli ...
\end{question}
\begin{Answer}
Lorem ipsum is not an answer to this question but this text will provide some dummy answer for two lines all together.
\end{Answer}
\end{document}
With
\NewEnviron{Answer}
{%
\noindent
\scalebox{1}[-1]{\rotatebox[origin=c]{180}{%
\noindent
\begin{minipage}[t]{\linewidth}
\begin{answer}
\BODY
\end{answer}%
\end{minipage}%
}%
}}%
one gets
but beware of those who bring mirrors ;)
In fact, with \scalebox
alone, the former orientations can be achieved without using \rotatebox
.
Last edit:
If you want to automatically show/hide answers here is a way. See the commented code lines
%\setboolean{answers}{true} %%% uncomment to show answers properly
\setboolean{answers}{false} %%% comment to show answers properly
Full code:
\documentclass{article}
\usepackage{rotating}
\usepackage[framemethod=tikz]{mdframed}
\newtheorem{question}{Question}
\mdfdefinestyle{que}{
linecolor=cyan,
backgroundcolor=cyan!20,
}
\surroundwithmdframed[style=que]{question}
\newtheorem{answer}{Answer}
\mdfdefinestyle{ans}{
linecolor=cyan,
backgroundcolor=yellow!20
% , rotatebox
}
\surroundwithmdframed[style=ans]{answer}
\usepackage{environ}
\usepackage{ifthen}
\newboolean{answers}
%\setboolean{answers}{true} %%% uncomment to show answers properly
\setboolean{answers}{false} %%% comment to show answers properly
\ifthenelse{\boolean{answers}}%
{%
\NewEnviron{Answer}
{%
\noindent
\begin{minipage}[t]{\linewidth}
\begin{answer}
\BODY
\end{answer}%
\end{minipage}% here put what the command has to do when outside
}%
}%
{\NewEnviron{Answer}
{%
\noindent
\scalebox{1}[-1]{%
\noindent
\begin{minipage}[t]{\linewidth}
\begin{answer}
\BODY
\end{answer}%
\end{minipage}%
}%
}%
}%
\begin{document}
\begin{question}
\textbf{E.coli.}
Escherichia coli ...
\end{question}
\begin{Answer}
Lorem ipsum is not an answer to this question but this text will provide some dummy answer for two lines all together.
\end{Answer}
\end{document}
With
\setboolean{answers}{false}
we get:
With
\setboolean{answers}{true}
we get:
With optional argument
\documentclass{article}
\usepackage{rotating}
\usepackage[framemethod=tikz]{mdframed}
\newtheorem{question}{Question}
\mdfdefinestyle{que}{
linecolor=cyan,
backgroundcolor=cyan!20,
}
\surroundwithmdframed[style=que]{question}
\newtheorem{answer}{Answer}
\mdfdefinestyle{ans}{
linecolor=cyan,
backgroundcolor=yellow!20
% , rotatebox
}
\surroundwithmdframed[style=ans]{answer}
\usepackage{environ}
\def\invert{-1}
\NewEnviron{Answer}[1][1]%
{%
\noindent
\scalebox{1}[#1]{%
\noindent
\begin{minipage}[t]{\linewidth}%
\begin{answer}
\BODY
\end{answer}%
\end{minipage}%
}%
}%
\begin{document}
\begin{question}
\textbf{E.coli.}
Escherichia coli ...
\end{question}
\begin{Answer}
Lorem ipsum is not an answer to this question but this text will provide some dummy answer for two lines all together.
\end{Answer}
\begin{question}
\textbf{E.coli.}
Escherichia coli ...
\end{question}
\begin{Answer}[\invert]
Lorem ipsum is not an answer to this question but this text will provide some dummy answer for two lines all together.
\end{Answer}
\end{document}
Best Answer
A solution that uses simple rules:
The same file translated into "pure LaTeX":
Remarks:
\mathbin
or\mathrel
to get the horizontal spacing right.