GeneralQED square in all environments

LaTeX specific issues not fitting into one of the other forums of this category.
latexforever
Posts: 120
Joined: Fri Nov 14, 2008 9:40 pm

QED square in all environments

Post by latexforever »

Hello everybody,

I simply want to add a QED square (the same as the one used to show a proof is finished) in the end of all my environments.

For example, if I define the environment "sample", I want, when using

Code: Select all

\begin{sample}
\end{sample}
, a QED square to be printed at the end of the sample environment.

What can I do? Thanks!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
drowsy
Posts: 44
Joined: Tue Dec 23, 2008 6:00 am

Re: QED square in all environments

Post by drowsy »

Please do not do that :D
latexforever
Posts: 120
Joined: Fri Nov 14, 2008 9:40 pm

Re: QED square in all environments

Post by latexforever »

Why? I only have two or three environments and I think it is nice. What can I do for a given environment? Thanks
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

QED square in all environments

Post by localghost »

You could incorporate a new command to all your own environments. A first approach could look like this.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{lmodern}
\usepackage{blindtext}

\parindent0em

\newcommand*{\signed}[1]{%
  \unskip\hspace*{1em plus 1fill}%
  \nolinebreak[3]\hspace*{\fill}%
  \mbox{#1}
}

\begin{document}
  \blindtext\signed{$\square$}
\end{document}
All predefined environments have to be redefined.


Best regards
Thorsten¹
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
latexforever
Posts: 120
Joined: Fri Nov 14, 2008 9:40 pm

QED square in all environments

Post by latexforever »

Ok, but if I define my environments using successively:

Code: Select all

\newtheoremstyle{theorem}%name
{10pt} % space above
{10pt} % space below
{\slshape} % bofy font
{\parindent} % ident - empty=no indent, \parindent= paragraph indent
{\bfseries} % thm head font
{. } % punctuation after thm head
{ } % space after thm head: `` ``=normal \newline=linebreak
{} % thm head specification
\theoremstyle{theorem}
\newtheorem{theorem}{\textcolor{red}{Thèorème}}[section]
\newtheorem{corollary}{\textcolor{orange}{Corollaire}}[section]
\newtheorem{proposition}{Proposition}[section]
\newtheorem{lemma}{\textcolor{green}{Lemme}}[section]
\newtheorem{property}{\textcolor{magenta}{Propriété}}[section]

\newtheoremstyle{exemple}
{10pt}{10pt}{\itshape \footnotesize}{}{\itshape \footnotesize}{.}{\newline}{}%{\thmnumber{{\upshape\bfseries#2.}\ }\thmname{#1}\thmnote{ #3}}
\theoremstyle{exemple}
\newtheorem{exemple}{\textcolor{brown}{Exemple}}[section]


\newtheoremstyle{defi}%name
{10pt} % space above
{10pt} % space below
{\rmfamily} % bofy font
{\parindent} % ident - empty=no indent, \parindent= paragraph indent
{\bfseries} % thm head font
{. } % punctuation after thm head
{ } % space after thm head: `` ``=normal \newline=linebreak
{} % thm head specification
\theoremstyle{defi}
\newtheorem{definition}{\textcolor{blue}{Définition}}[section]
, how do I put the code your proposed into mine?
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

QED square in all environments

Post by localghost »

You talked about environments, not about theorems. This is simply done with the amsthm package.

Code: Select all

\documentclass[english]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage{amsthm}
\usepackage{lmodern}
\usepackage{xcolor}
\usepackage{blindtext}

\setlength{\parindent}{0em}

\newtheoremstyle{theorem}  % name
  {10pt}        % space above
  {10pt}        % space below
  {\slshape}    % body font
  {\parindent}  % indent - empty=no indent, \parindent= paragraph indent
  {\bfseries}   % theorem head font
  {. }          % punctuation after theorem head
  { }           % space after theorem head: " "=normal \newline=linebreak
  {}            % theorem head specification

\theoremstyle{theorem}
\newtheorem{theorem}{\textcolor{red}{Thèorème}}[section]
\newtheorem{corollary}{\textcolor{orange}{Corollaire}}[section]
\newtheorem{proposition}{Proposition}[section]
\newtheorem{lemma}{\textcolor{green}{Lemme}}[section]
\newtheorem{property}{\textcolor{magenta}{Propriété}}[section]

\begin{document}
  \begin{theorem}
    \blindtext
    \qed
  \end{theorem}
\end{document}
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
latexforever
Posts: 120
Joined: Fri Nov 14, 2008 9:40 pm

Re: QED square in all environments

Post by latexforever »

Sorry. And is there no way to make this process automatic?
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

QED square in all environments

Post by localghost »

latexforever wrote:Sorry. And is there no way to make this process automatic?
I think you should be grateful (like me) that it can be done so easy. And hitting four keys to get that shouldn't cause too much inconvenience. Otherwise take a look at the package code and redefine the critical parts.
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
latexforever
Posts: 120
Joined: Fri Nov 14, 2008 9:40 pm

Re: QED square in all environments

Post by latexforever »

Thanks. Yes, it is a very easy thing to do, but I thought it could be specified in the theorems' options.

Thanks for everything.
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

QED square in all environments

Post by localghost »

Finally I found a possible solution that may be better. Take a look at the ntheorem package. It lets you specify a kind of end-of-theorem symbol.
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
Post Reply