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.

When I compile the following document, I get the error

LaTeX Error: Something's wrong--perhaps a missing \item.

\documentclass[11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsthm,amssymb,enumerate}

\begin{document}

\newtheorem{defi}{Definição}[section]

\newcommand{\cuatex}[3]
{\begin{center}
\setlength{\unitlength}{2.54cm}
\begin{picture}(#1,#2)
\put(0,0){\framebox(#1,#2){\begin{minipage}{12.5cm}#3\end{minipage}}}
\end{picture}
\end{center}}

\newcommand{\Defi}[2]
{\cuatex{5.2}{#1}{
\begin{defi}
#2
\end{defi}
}}

\chapter{Chapter I}
\section{Section 1}
This is only a test.

\Defi{2.1}{Diremos que un conjunto no vacío $X$ es un espacio métrico,
si sobre él está definida una función
$$
d:X\times X
$$
satisfaciendo las siguientes propriedades
\begin{itemize}
\item $d(x,y)=0$ si, y solamente si $x=y$.
\item La función $d$ es simétrica, esto es, $d(x,y)=d(y,x)$
\item $d(x,z)\leq d(x,y)+d(y,z)$ (desigualdad triangular)
\end{itemize}
La función $d$ es llamada métrica.
}
\end{document}
share|improve this question
    
But if I want to add \put(0,0){\special{eps:quadrado.eps x=5.2 in y=\yVal in}} before \put(0,0){\framebox(5.2,\yVal){\usebox\DBox}} How can I simplify the environment so that "Definição 1.1.1." is inside the box? –  Luo Kaisa Jun 15 at 2:21

2 Answers 2

Use an environment instead of a command and also \fbox:

\documentclass[11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsthm,amssymb,enumerate}
\begin{document}

\newtheorem{defi}{Definição}[section]

\newsavebox\DBox
\newenvironment{Defi}[1]
  {\gdef\yVal{#1}%
   \begin{lrbox}{\DBox}
   \minipage{12.5cm}\begin{defi}}
  {\end{defi}   
   \endminipage\end{lrbox}%
   \par\noindent\fbox{\usebox\DBox}}

\chapter{Chapter I}
\section{Section 1}
This is only a test.

\begin{Defi}{2.1}
Diremos que un conjunto no vacío $X$ es un espacio métrico,
si sobre él está definida una función
$$
d:X\times X
$$
satisfaciendo las siguientes propriedades
\begin{itemize}
\item $d(x,y)=0$ si, y solamente si $x=y$.
\item La función $d$ es simétrica, esto es, $d(x,y)=d(y,x)$
\item $d(x,z)\leq d(x,y)+d(y,z)$ (desigualdad triangular)
\end{itemize}
La función $d$ es llamada métrica.
\end{Defi}

\end{document}

enter image description here

share|improve this answer
    
Thanks a lot @Herbert but "Definição 1.1.1." should appear inside the box as in: maya-tech.us/images/test.png –  Luo Kaisa Jun 14 at 16:04
    
see my edited answer –  Herbert Jun 14 at 16:27

I suggest you to use mdframed:

\documentclass[11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsthm,amssymb,mdframed}

\begin{document}

\theoremstyle{definition}
\newmdtheoremenv[
  innertopmargin=-1ex,
]{defi}{Definição}[section]

\chapter{Chapter I}
\section{Section 1}
This is only a test for stating definition~\ref{defi:metric}

\begin{defi}\label{defi:metric}
Diremos que un conjunto no vacío $X$ es un espacio métrico,
si sobre él está definida una función
\[
d\colon X\times X\to\mathbb{R}
\]
satisfaciendo las siguientes propriedades
\begin{itemize}
\item $d(x,y)=0$ si, y solamente si $x=y$.
\item La función $d$ es simétrica, esto es, $d(x,y)=d(y,x)$
\item $d(x,z)\leq d(x,y)+d(y,z)$ (desigualdad triangular)
\end{itemize}
La función $d$ es llamada métrica.
\end{defi}

Some text below.
\end{document}

enter image description here

Note that $$...$$ should never be used in LaTeX, see Why is \[ … \] preferable to $$?

share|improve this answer
    
Thanks @egreg, but when I run it I get: ! Undefined control sequence. l.8 \newmdtheoremenv [ ? –  Luo Kaisa Jun 14 at 22:37
    
@LuoKaisa You have an outdated version of mdframed; you should update your TeX distribution. –  egreg Jun 14 at 22:39
    
I did an update to TeXLive 2013 and after running the same tex file I get !source –  Luo Kaisa Jun 15 at 0:01
    
@LuoKaisa Strange; remove innertopmargin=-1ex, –  egreg Jun 15 at 0:18
    
I removed it, and it looks fine, but if I change the zoom of the pdf, then some box lines disappear, depending on the zoom rate. For example, with 100% zoom, the horizontal and left lines disappear; with 75% the horizontal line disappear; with 125% the left line disappear... That doesn't happen with the solution from @herbert. –  Luo Kaisa Jun 15 at 2:11

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.