2

I have the following \definition command/theorem (I don't really know much about LaTeX):

\newtheoremstyle{definition}
  {0.8cm}
  {0.8cm}
  {}
  {0.4cm}
  {\bfseries}
  {.}
  {0.4cm}
  {}
\theoremstyle{definition} \newtheorem{definition}{Definition}[section]

Which yields definitions the way I like, with the numbering, etc., but I would want a starred version \definition* that does not have any numbering, at all. The best thing I've tried, so far, is changing last line for (and wrapping inside \makeatletter and \makeatother):

\theoremstyle{definition} \newtheorem{definition}{Definition}\@ifstar{[section]}{}

because I've seen people do something similar in other commands (I don't know how any of this works, "programming" syntax in LaTeX is very confusing to me). But this yields definition number with the definitions, anyway, so it would print "Definition 1." for the first definition, "Definition 2." for the second, etc.

Another problem I have with this is that I (like to) write the things as follows:

\definition{%
  A \emph{\textbf{heterogeneous system}} is one that contains two or more co- 
existent phases. 
}{\label{definition:heterogeneous-system}}

but then the labels appear as inexistent. Is there any way to make that syntax work, with the previous way of defining the definitions? Or do I have to forcibly use the \begin \end syntax? If the latter, how would I do a starred version of it?

Thanks in advance.

Edit: copy-paste material:

\documentclass[a4paper,3.3mm]{article}

\usepackage{amsthm}

\newtheoremstyle{definition}
  {0.8cm}
  {0.8cm}
  {}
  {0.4cm}
  {\bfseries}
  {.}
  {0.4cm}
  {}
\theoremstyle{definition} \newtheorem{definition}{Definition}[section]

\begin{document}

\section{Section number one}

\definition{%
  Some definition, has numbering 1.1.
}{\label{definition:1}}

\definition*{%
  Some other definition, should have no numbering at all.
}{\label{definition:2}}

\end{document}

I also would ideally want to be able to cite the definitions and have it show the numbering if they have it or something else if they don't (ideally a customizable hyperlink). This is optional however, so \cite{definition:1} would just print 1.1. (with the usual hyperlink) and \cite{definition:2}[text] would print text with a hyperlink to the definition.

  • It would be helpful if you composed a fully compilable minimal working example (MWE) including \documentclass and the appropriate packages that sets up the problem. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem. – user36296 Mar 25 at 16:12
  • @samcarter as far as I know, the only package this uses is the amsthm package. Besides that, it's not a problem, more so a fairly simple question, so I expected people to be able to answer without really having to debug anything. I will write something for them to copy-paste however. – mariogarcc Mar 25 at 16:17
  • You are missing the point of sam's comment. If you want help, it behooves you to provide as much information as possible to those who would help you. On this site, an MWE is considered a required part of the question. – Steven B. Segletes Mar 25 at 16:22
  • @StevenB.Segletes understood, let me know if you need something else. – mariogarcc Mar 25 at 16:33
  • When you say "no numbering at all", do you mean just the word Definition., or not even that? – Steven B. Segletes Mar 25 at 16:42
3

You're misusing the commands. With \newtheorem{definition}{Definition} you are defining an environment. The fact that \definition exists is just for implementation reasons and it's not a command with two arguments as you seem to believe.

\documentclass[a4paper]{article}

\usepackage{amsthm}

\newtheoremstyle{definition}
  {0.8cm}
  {0.8cm}
  {}
  {0.4cm}
  {\bfseries}
  {.}
  {0.4cm}
  {}
\theoremstyle{definition} 
\newtheorem{definition}{Definition}[section]
\newtheorem*{definition*}{Definition}

\begin{document}

\section{Section number one}

\begin{definition}\label{definition:1}
Some definition, has numbering 1.1.
\end{definition}

\begin{definition*}  
Some other definition, should have no numbering at all.
\end{definition*}

\end{document}

enter image description here

Just look at the following example to see what happens with your syntax.

\documentclass[a4paper]{article}

\usepackage{amsthm}

\newtheorem{theorem}{Theorem}[section]

\begin{document}

\section{Section number one}

\theorem{A theorem}{\label{x}}

Some text after the theorem.

\end{document}

enter image description here

  • I see, thank you for the clarification. But I'm having troubles to cite, as it cites them with a ? symbol instead of with their numbering, even with the one that has numbering indeed. Any ideas? I would expect the ? symbol in the starred one, but not in the "main" one. – mariogarcc Mar 25 at 16:53
  • @mariogarcc With cross references (\ref) or citations (\cite)? They're very different commands. To access the number of the definition you need \ref{definition:1}. – egreg Mar 25 at 16:54
  • Oops, true. But if I cite the one without numbering, a 1 appears in this case. I suppose I will have to use the hyperref package for those? – mariogarcc Mar 25 at 16:57
  • 1
    @mariogarcc If the definition has no number, what should be the reference? – egreg Mar 25 at 16:59
  • If you're asking me, I would require a obligatory argument between square brackets or just print a ? like \cite does, but that's why I asked if I had to use the hyperref package for that. – mariogarcc Mar 25 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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