Math & Sciencenewtheoremstyle

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
allevo
Posts: 49
Joined: Sat Apr 11, 2009 12:09 pm

newtheoremstyle

Post by allevo »

hi!!!
i'd like create a newtheoremestyle. i wrote this but generate an error:

Code: Select all

\newtheoremstyle{examplestyle}% name of the style to be used
  {10mm}% measure of space to leave above the theorem. E.g.: 3pt
  {10mm}% measure of space to leave below the theorem. E.g.: 3pt
  {\slshape}% name of font to use in the body of the theorem
  {6pt}% measure of space to indent
  {\bfseries}% name of head font
  {\newline}% punctuation between head and body
  {10mm}% space after theorem head
  {}% Manually specify head
\theoremstyle{examplestyle}
\newtheorem{example}{Esempio}

\begin{document}
.....

\begin{example}
\\
\begin{enumerate}
\item ipotesi da dimostrare: “non tutte le preposizione sono esatte”
\item opposto della tesi : “tutte le preposizioni sono esatte”
\item A è uguale a 1
\item B è uguale a 4
\item A = B
\item A non può essere uguale a B se vale 1 quindi la proposizione “tutte
le preposizioni sono esatte” è errata
\item l'ipotesi è esatta
\end{enumerate}
\end{example}

....
\end{document}
the error is this:

Code: Select all

! LaTeX Error: There's no line here to end.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.120 \begin
            {enumerate}
i put '\\' because i wish that the body is below the head.
where do i wrong?!?

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

newtheoremstyle

Post by localghost »

Omit the \\ command for a line break at the beginning of the new example theorem environment.


Best regards
Thorsten¹
allevo
Posts: 49
Joined: Sat Apr 11, 2009 12:09 pm

Re: newtheoremstyle

Post by allevo »

but i'd like put a \newline
i'd want that the head isn't on same line
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

newtheoremstyle

Post by localghost »

Prepare a minimal working example (MWE) with the package you are using to setup the theorem style. Some packages offer to have a line break when declaring the style in the preamble. Please get used to presenting a MWE for future requests. This can spare a lot of time.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

newtheoremstyle

Post by Stefan Kottwitz »

Hi Allevo,

your example code could be fixed by inserting \leavevmode before \\:

Code: Select all

\begin{example}
    \leavevmode\\
    \begin{enumerate}
...
Stefan
LaTeX.org admin
allevo
Posts: 49
Joined: Sat Apr 11, 2009 12:09 pm

newtheoremstyle

Post by allevo »

excuse me
this is the code

Code: Select all

\documentclass{book}

\usepackage{amsthm}
\newtheoremstyle{examplestyle}{10mm}{10mm}{\slshape}{6pt}{\bfseries}{\newline}{10mm}{}
\theoremstyle{examplestyle}
\newtheorem{example}{Esempio}

\begin{document}

\begin{example}
\begin{enumerate}
\item foo
\end{enumerate}
\end{example}

\end{document}
i put \newline but the head 'Esempio' is on the same line of "foo"
how can i do to put the "foo"'s line below the title?

example:
Esempio
1. foo


EDIT:
i don't see

Code: Select all

\leavevmove \\
with this, there aren't errors !!
thank!!
but what is leavevmove?!?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

newtheoremstyle

Post by localghost »

The misbehaviour is caused by the enumerate environment. An invisible blank space will do the trick.

Code: Select all

\documentclass[11pt,a4paper,italian]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage{amsmath}
\usepackage{amsthm}

\parindent0em

\newtheoremstyle{examplestyle}  % name of the style to be used
  {10mm}       % measure of space to leave above the theorem. E.g.: 3pt
  {10mm}       % measure of space to leave below the theorem. E.g.: 3pt
  {\slshape}   % name of font to use in the body of the theorem
  {6pt}        % measure of space to indent
  {\bfseries}  % name of head font
  {\newline}   % punctuation between head and body
  {10mm}       % space after theorem head
  {}           % Manually specify head
\theoremstyle{examplestyle}
\newtheorem{example}{Esempio}

\begin{document}
  \begin{example}
    ~
    \begin{enumerate}
      \item foo
      \item bar
    \end{enumerate}
  \end{example}
\end{document}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

newtheoremstyle

Post by Stefan Kottwitz »

allevo wrote:but what is leavevmode?
\leavevmode switches from vertical mode to horizontal mode, needed for \newline, that wouldn't work in vertical mode.

Stefan
LaTeX.org admin
allevo
Posts: 49
Joined: Sat Apr 11, 2009 12:09 pm

newtheoremstyle

Post by allevo »

thank a million!!!
but in this example there are an another error :(

Code: Select all

\documentclass{book}

\usepackage{amsthm}
\newtheoremstyle{paradoxestyle}{5mm}{0mm}{\texttt}{0pt}{\bfseries}{}{0mm}{}
\theoremstyle{paradoxestyle}
\newtheorem*{paradoxe}{Paradosso}

\begin{document}

\begin{paradoxe}
\leavevmode \\
ciao!!
\end{paradoxe}

\end{document}
the error is this :

Code: Select all

Something's wrong--perhaps a missing \item.
where do i wrong?!
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

newtheoremstyle

Post by Stefan Kottwitz »

Use \ttfamily instead of \texttt:

Code: Select all

\newtheoremstyle{paradoxestyle}{5mm}{0mm}{\ttfamily}{0pt}{\bfseries}{}{0mm}{}
Stefan
LaTeX.org admin
Post Reply