Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I get many times things that are somehow related to the main topic and should be separated by blue background, for instance.

I do at the moment only

\documentclass{article}
\newtheorem{theorem}{Theorem}
\newtheorem{question}[theorem]{Question}
\begin{document}
\begin{question}
Lorem ipsum?
\end{question}
\end{document}

I get like this

enter image description here

where the question -environment only adds the question mark to the front. I think there is some problem because the environment should be numbered, first of all.

How can you make distinguish the question environment better?

share|improve this question
1  
Related Question: Environments for visually setting text apart. –  Peter Grill Feb 20 at 18:46
    
Do you want the structure to be numbered? –  Gonzalo Medina Feb 20 at 19:22
add comment

1 Answer 1

up vote 6 down vote accepted

There are many ways, and it all depends on the desired final layout. Below, two options: one using the standard quote environment; the other one using mdframed:

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

\newmdenv[linecolor=cyan,backgroundcolor=cyan!20]{question}

\begin{document}

\lipsum[2]
\begin{quote}
\lipsum[2]
\end{quote}
\lipsum[2]
\begin{question}
\lipsum[2]
\end{question}
\lipsum[2]

\end{document}

enter image description here

And with tcolorbox:

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{most}
\usepackage{lipsum}

\newtcolorbox{question}{breakable,colframe=cyan,colback=cyan!20}

\begin{document}

\lipsum[2]
\begin{question}
\lipsum[2]
\end{question}
\lipsum[2]

\end{document}

enter image description here

Another option using a list through changepage:

\documentclass{article}
\usepackage{changepage}
\usepackage{lipsum}

\newenvironment{question}
  {\par\smallskip\begin{adjustwidth}{1em}{1em}\small\itshape}
  {\end{adjustwidth}\par\smallskip}

\begin{document}

\lipsum[2]
\begin{question}
\lipsum[2]
\end{question}
\lipsum[2]

\end{document}

enter image description here

The options using mdframed and tcolorbox offer you many customization possibilities; please refer to the documentation of the packages.

For example, you can define your structure as a theorem-like block using, for example, amsthm and then surround it with a mdframed:

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

\newtheorem{question}{Question}
\mdfdefinestyle{que}{
  linecolor=cyan,
  backgroundcolor=cyan!20,
}
\surroundwithmdframed[style=que]{question}

\begin{document}

\lipsum[2]
\begin{question}
\lipsum[2]
\end{question}
\lipsum[2]

\end{document}

enter image description here

A numbered structure with tcolorbox:

\documentclass{article}
\usepackage{tcolorbox}
\usepackage{lipsum}

\newtcolorbox[auto counter]
  {question}
  {colback=cyan!20,colframe=cyan,fonttitle=\bfseries,
  title=Question~\thetcbcounter}

\begin{document}

\lipsum[2]
\begin{question}
\lipsum[2]
\end{question}
\lipsum[2]

\end{document}

enter image description here

share|improve this answer
    
Thank you very much for your clear answer! I like most the last proposal with mdframed and tcolor box because of cusmotisation possibilities. –  Masi Feb 20 at 19:48
    
I like your update now most (the last option with numbered structure). :) –  Masi Feb 20 at 19:49
    
@Masi You're welcome! –  Gonzalo Medina Feb 20 at 19:49
1  
@Masi No, no need to add anything else in my examples; looking at the error messages, it seems that you are using an old version of tcolorbox. I am using version 2.70 (2014/02/06). –  Gonzalo Medina Feb 20 at 20:05
1  
Thank you for your feedback! I opened a new question here tex.stackexchange.com/questions/161809/… –  Masi Feb 22 at 14:55
show 11 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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