0

I've tried using flushleft with bolds such as

\begin{flushleft}{\medium{\textbf{Example 1}}\end{flushleft}

but that makes a large space right after.

Notice the text is all the way to the left of the pdf, there is minimal space between it and the next paragraph, the the paragraph is indented.

enter image description here

  • 1
    See the documentation of the amsthm and ntheorem packages. – GuM Feb 05 '17 at 00:45
  • See Section 4 of the documentation of the amsthm package. – GuM Feb 05 '17 at 00:49
  • 1
    You also can look at the thmtools package, which cooperates with amsthm as well as ntheorem. – Bernard Feb 05 '17 at 00:54
  • Altering which packages? – Bernard Feb 05 '17 at 01:10
  • In that case, I suggest that you ask your professor exactly what means you are allowed to use. I’m sure that she or he prefer that you consult her/him rather than the Internet community… ;-) – GuM Feb 05 '17 at 01:12
  • @Quantitative -- no alteration of package amsthm necessary. see Non italic text in theorems, definitions, examples and the amsthm documentation (texdoc amsthm) for details. – barbara beeton Feb 05 '17 at 02:30
  • You can delete the question yourself, no? – Mico Apr 19 '17 at 21:36
  • 2
    @Mico not if it has answers, and I have to say, if I lost 40 points because a user had 'changed their mind' I would be a bit disappointed and would like it to be a little more difficult for someone to do it on two other questions to 5 other answerers, that's usually counted as vandalism on SE – Au101 Apr 19 '17 at 22:06
  • 1
    @Au101 - Good points! – Mico Apr 19 '17 at 22:09
  • 2
    Why is this being closed as offtopic? I understand the OP is basically vandalizing their own question, but the solution to that may be something like blocking the user or politely telling them not to edit this question anymore? – ShreevatsaR Apr 20 '17 at 02:50

3 Answers3

5

Here's an example with thmtools to let you start.

\documentclass{article}
\usepackage{lipsum} % for dummy text

\usepackage{amsthm,thmtools}

\declaretheoremstyle[%
  spaceabove    = \topsep,
  spacebelow    = \topsep,
  bodyfont      = \itshape,
  headpunct     = ,
  postheadspace = 1em]%
{definition}

\declaretheoremstyle[%
  spaceabove    = \topsep,
  spacebelow    = \topsep,
  headpunct     = ,
  postheadspace = \newline,
  postheadhook  = {\hspace*{\parindent}}]%
{example}

\declaretheoremstyle[%
  spaceabove    = \topsep,
  spacebelow    = \topsep,
  headpunct     = ,
  postheadspace = \newline,
  postheadhook  = {\hspace*{\parindent}}]%
{solution}

\declaretheorem[style=definition,name=Definition]{defn}

\declaretheorem[style=example,numberlike=defn,name=Example]{ex}

\declaretheorem[style=solution,numbered=no,name=Solution]{sol}

\begin{document}
\begin{defn}
\lipsum*[2]
\end{defn}

\begin{ex}
\lipsum*[2]
\end{ex}

\begin{sol}
\lipsum*[2]
\end{sol}
\end{document}

Output:

enter image description here

and an example without theorems...

\documentclass{article}
\usepackage{lipsum} % for dummy text

\newcounter{defn}
\newcommand{\Def}{\refstepcounter{defn}\vspace*{\topsep}\noindent\textbf{Definition \thedefn}\hspace*{1em}}
\newcommand{\Ex}{\refstepcounter{defn}\vspace*{\topsep}\noindent\textbf{Example \thedefn}\par}
\newcommand{\Sol}{\vspace*{\topsep}\noindent\textbf{Solution}\par}

\begin{document}
\Def{\itshape\lipsum*[2]}

\Ex\lipsum*[2]

\Sol\lipsum*[2]
\end{document}

Output:

enter image description here

karlkoeller
  • 124,410
2

If it's an introduction to LaTeX, maybe the OP is looking to something manual and basic like

\noindent\textbf{Example}\par
\indent text text text

?

Rmano
  • 40,848
  • 3
  • 64
  • 125
1

A simple code with ntheorem. I don't think the 1st paragraph indent is nice, so I didn't set it. It can be inserted with a small patch of the break and nonumberbreak theorem styles defined by ntheorem.

\documentclass{report}%]

\usepackage[utf8]{inputenc}%
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage[thmmarks, amsmath]{ntheorem}%

\theoremstyle{break}
\theoremheaderfont{\bfseries\upshape}
\theorembodyfont{\mdseries\hspace*{1em}}
\theoremseparator{\smallskip}
\newtheorem{example}{Example}[section]
\renewcommand\theexample{\arabic{example}}
\theoremstyle{nonumberbreak}
\newtheorem{solution}{Solution}


\begin{document}

\begin{example} \label{ex-1}
 Some example%
\end{example}

\begin{solution}
Some solution for example \ref{ex-1}. 
\end{solution}

\end{document} 

enter image description here

Bernard
  • 271,350
  • @Quantitative:I tried to reproduce the image you posted, to make clear that all theorem-like (numbered) structures share the same counter. I can modify the code, but what's not clear to me is whether the vertical spacing between example and solution is OK for you? – Bernard Apr 20 '17 at 08:52
  • @Quantative: I've modified my answer to a minimalistic one. – Bernard Apr 20 '17 at 16:04