Document ClassesProblem with amsthm

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
luozi
Posts: 2
Joined: Mon Jun 02, 2014 4:38 pm

Problem with amsthm

Post by luozi »

What is wrong with the following code?:

Code: Select all

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

\begin{document}

\newtheorem{defi}{Definición}[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{Capítulo I}
\section{Sección 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 \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{document}
Each time I run it with latex or pdflatex, I always get:

Code: Select all

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

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.40 }
If I remove amsthm from the \usepackage, it compiles fine, but I would like to have it included. I suspect it is a conflict with amsthm.sty. Is there are workaround for it?

Many thanks in advance,

--
Luozi

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Problem with amsthm

Post by Johannes_B »

Is there any reason why you are going through all that trouble?
You can use package mdframed to get yu definitions framed. Please see below.
Hint, you can click on »Open in writelatex« to see the output.

Code: Select all

\documentclass[11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, amsthm, amssymb, enumerate}
\usepackage{mdframed}
\newtheorem{defi}{Definición}[section]
\surroundwithmdframed{defi}

\usepackage{showframe}
\begin{document}

\chapter{Capítulo I}
\section{Sección 1}
This is only a test.

\begin{defi}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 \to \mathbb{R}
\]%Better use LaTeX syntax
	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}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
luozi
Posts: 2
Joined: Mon Jun 02, 2014 4:38 pm

Problem with amsthm

Post by luozi »

Thanks for the answer. Actually my \cuatex newcommmand is defined as:

Code: Select all

\newcommand{\cuatex}[3]
{\begin{center}
\setlength{\unitlength}{2.54cm}
\begin{picture}(#1,#2)
\put(0,0){\special{eps:quadrado.eps x=#1 in y=#2 in}}
\put(0,0){\framebox(#1,#2){\begin{minipage}{12.5cm}#3\end{minipage}}}
\end{picture}
\end{center}}
As you see, I'm including a customized eps inside the framebox. How can
I use it with mdframed?

On the other hand, there is a problem when using mdframed and converting
the code to pdf:
If I change the zoom on 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 and so on.


Many thanks in advance,

--
Luozi
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Problem with amsthm

Post by Johannes_B »

Hi and sorry for the late reply. Can you give an example, maybe a
screenshot of the desired output you want to achieve? Right now i
have trouble imagining result.

Line thickness and zoom levels are a common seen reason for disturbance. It is jusst a viewer thing, try out another one, or even another version. Almost sure, everything will look great in print.
EDIT: I've been told, that this problem can be resolved by loading mdframed with the tikz option.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply