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.

Basically, what I'd like is to have an elegant command that would enable descriptions (commutativity, associativity, etc.) made alongside enumerated statements to be aligned to the far right side of the grey box that is surrounding my theorem environment. I would appreciate any code or suggestions that would resolve this matter.

This is the output I get from the minimal code below the image: enter image description here

    \documentclass[english,nohyper]{tufte-handout}
    \usepackage{amsthm}
    \usepackage{amsmath}


    \usepackage{enumitem}       % customizable list environments
    \newtheorem{thm}{\protect\theoremname}


    \usepackage{framed} % responsible for creating gray box around environment
    \definecolor{shadecolor}{RGB}{236,236,236}
    \providecommand{\theoremname}{Theorem}

    \begin{document}
    \begin{snugshade} % begins gray box around thm
    \begin{thm}
    let so and so be, then:
    \begin{enumerate}[labelindent=0pt,leftmargin=*,widest= a,label=\textup{\textbf{(\alph*)}}]
    \item $A+B=B+A\quad\text{commutativity}$
    \item $A+\left(B+C\right)=\left(A+B\right)+C\quad\text{associativity}$
    \item $O+A=A+O=A\quad\text{identity}$
    \item $A+\left(-A\right)=O\quad\text{inverse}$
    \end{enumerate}
    \end{thm}
    \end{snugshade} % ends gray box around thm
    \end{document}
share|improve this question

1 Answer 1

up vote 10 down vote accepted

Instead of \quad, use \hspace{\fill}:

\documentclass[english,nohyper]{tufte-handout}
\usepackage{amsthm}
\usepackage{amsmath}


\usepackage{enumitem}       % customizable list environments
\newtheorem{thm}{\protect\theoremname}


\usepackage{framed} %creates gray box around environment
\definecolor{shadecolor}{RGB}{236,236,236}
\providecommand{\theoremname}{Theorem}

\begin{document}
\begin{snugshade}
\begin{thm}
let so and so be, then:    
\begin{enumerate}[labelindent=0pt,leftmargin=*,widest= a,label=\textup{\textbf{(\alph*)}}]
\item $A+B=B+A \hspace{\fill}\text{commutativity}$
\item $A+\left(B+C\right)=\left(A+B\right)+C \hspace{\fill}\text{associativity}$
\item $O+A=A+O=A \hspace{\fill}\text{identity}$
\item $A+\left(-A\right)=O\hspace{\fill}\text{inverse}$
\end{enumerate}
\end{thm}
\end{snugshade}
\end{document}

enter image description here

Update As suggested by Chris (cmhughes), you can use elegant mdframed package for putting frames etc, and it is highly customizable.. Check out the mdframed manual and some examples by running texdoc mdframed from command prompt. Here is a minimal example using mdframed:

\documentclass[english,nohyper]{tufte-handout}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{enumitem}       % customizable list environments
\newtheorem{thm}{\protect\theoremname}
\usepackage[framemethod=default]{mdframed}
\usepackage{framed} % responsible for creating gray box around environment
\definecolor{shadecolor}{RGB}{236,236,236}
\providecommand{\theoremname}{Theorem}
\mdfdefinestyle{theoremstyle}{%
linecolor=red,linewidth=.5pt,%
frametitlerule=true,%
frametitlebackgroundcolor=gray!30,
backgroundcolor=gray!10,
innertopmargin=\topskip,
}
\newenvironment{mdthm}
{\begin{mdframed}[style=theoremstyle]\begin{thm}}
{\end{thm}\end{mdframed}}

\begin{document}
\begin{mdthm}
let so and so be, then:
\begin{enumerate}[labelindent=0pt,leftmargin=*,widest=a,label=\textup{\textbf{(\alph*)}}]
\item $A+B=B+A\hspace{\fill}\text{commutativity}$
\item $A+\left(B+C\right)=\left(A+B\right)+C\hspace{\fill}\text{associativity}$
\item $O+A=A+O=A\hspace{\fill}\text{identity}$
\item $A+\left(-A\right)=O\hspace{\fill}\text{inverse}$
\end{enumerate}
\end{mdthm}

\mdtheorem[style=theoremstyle]{thmm}{Theorem}
Another style with some change:
\begin{thmm}[\normalfont let so and so be, then:]
\begin{enumerate}[labelindent=0pt,leftmargin=*,widest= a,label=\textup{\textbf{(\alph*)}}]
\item $A+B=B+A \hspace{\fill}\text{commutativity}$
\item $A+\left(B+C\right)=\left(A+B\right)+C \hspace{\fill}\text{associativity}$
\item $O+A=A+O=A \hspace{\fill}\text{identity}$
\item $A+\left(-A\right)=O\hspace{\fill}\text{inverse}$
\end{enumerate}
\end{thmm}
\end{document}

enter image description here

share|improve this answer
    
This is just what I needed. Thank you very much. –  Black Milk Oct 18 '12 at 23:10
1  
@EdwinMontufar Glad it helped. In this site, thanks are better conveyed by upvoting the answers and accepting those answers (by clicking the green check below vote count) which helped you most. This is our tradition here :) –  Harish Kumar Oct 18 '12 at 23:14
1  
+1 I completely misunderstood the question :) could you put a solution using mdframed and ditch the framed package? –  cmhughes Oct 18 '12 at 23:18
    
@cmhughes: Thank you :) MWE added for mdframed :) –  Harish Kumar Oct 18 '12 at 23:57

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.