Tag Info

Hot answers tagged

9

I would use \text like this: \documentclass{article} \usepackage{amsmath} \begin{document} \begin{equation} \text{All $x$ are $y$; all $y$ are $z$; therefore, all $x$ are $z$.} \end{equation} \end{document}


8

This does what you want, though I find it cumbersome and not really informative. \documentclass{book} \usepackage{amsthm,xpatch} \makeatletter \let\qed@empty\openbox % <--- change here, if desired \def\@begintheorem#1#2[#3]{% \deferred@thm@head{% \the\thm@headfont\thm@indent \@ifempty{#1} {\let\thmname\@gobble} ...


7

If we use the amsthm package then we can do this by hijacking the \qedsymbol command and hacking the way that the theorem environments are constructed internally. This comes down to adding some code to \@begintheorem to overwrite \qedsymbol so that it becomes a boxed version of the last theorem number. There are two issues with the code below. The first ...


6

You can store the "message" in the main vertical list about the end of previous environment using very specific value of penalty. And you can read this value at the start of your environment. \newenvironment{env} {\ifnum\lastpenalty=12345 \vskip-\bigskipamount \penalty0 \fi \addvspace{\bigskipamount}\bfseries} ...


6

\documentclass{article} \newenvironment{example}{\par\hrule\bfseries}{\par\hrule} \makeatletter \def\CloseEverything{% \expandafter\end\expandafter{\@currenvir}\CloseEverything } \makeatother \begin{document} \begin{example} \begin{enumerate} \item blah \item blah \CloseEverything


5

Like this? \documentclass{article} \usepackage{enumitem,showframe} %% showframe only for demo \newlist{mylist}{itemize}{1} \setlist[mylist]{leftmargin=*} \begin{document} \begin{mylist}[{label=\makebox[3cm][l]{\bfseries Title}}] \item title 1 \\ title 2 \item Title \end{mylist} \begin{mylist}[label={\makebox[3cm][l]{\bfseries How}}] ...


5

For lists I'd recommend you use the enumitem package and use the newlist facility that is built in. If you have many of these you could use \newcommand{\DefineNewList}[3]{% % #1 = name % #2 = max depth % #3 = label \newlist{#1}{enumerate}{#2} \setlist[#1]{label*=#3} }% but I don't see much value in that. Code: ...


4

After a small fight with it (first time using prop) I think this works, although it's a bit of a mix of things, and may it would be better to think of a better “user interface”. First, you have an environment cryptolist which is like an enumerate except that \item{…} does have an argument. cryptolist has an optional argument which is the name of the list ...


4

Loop Space's answer is good, but has the disadvantage of clobbering the optional argument, so attribution can't be specified any more. I'd suggest using a mandatory argument. \documentclass{article} \usepackage{amsthm} \swapnumbers % optional, of course \newtheorem{thm}{Theorem}[section] % the main one \newtheorem{lemma}[thm]{Lemma} % other statement ...


4

The symbol must be inserted at the end of the environment, 'flushed' right, so use \hfill\myqedsymbol where \myqedsymbol is a macro wrapper for the particular symbol (\triangle in this case) \documentclass{article} \usepackage{amsthm} \usepackage{hyperref} \theoremstyle{plain} \newtheorem{theorem}{Theorem}[section] \theoremstyle{definition} ...


4

If you define your environment as \newenvironment{myenvironment}[1]{\taggedblock{#1}}{\endtaggedblock} then things work: Note: I have seen this trick used when wrapping environment around tabular but not sure why it is needed. Code: \documentclass[10pt,a4paper]{article} \usepackage[latin1]{inputenc} \usepackage{amsmath} \usepackage{amsfonts} ...


3

You could use the same mechanism as section titles: \documentclass{article} \usepackage{amsthm} \usepackage{lipsum} \newtheorem{theorem}{Theorem} \makeatletter \newcommand{\proofpart}[2]{% \par \addvspace{\medskipamount}% \noindent\emph{Part #1: #2}\par\nobreak \addvspace{\smallskipamount}% \@afterheading } \makeatother \begin{document} ...


3

Your problem is not the square brackets: it's the definition of the matrix environment. If you do \show\matrix you get > \matrix=macro: #1->\null \,\vcenter {\normalbaselines \m@th \ialign {\hfil $##$\hfil &&\quad \ hfil $##$\hfil \crcr \mathstrut \crcr \noalign {\kern -\baselineskip } #1\crcr \mathstrut \crcr \noalign {\kern -\baselineskip ...


3

Why define \foo? May be I missed something but you can inglude \csname inside the definitions \newenvironment{variables} {\paragraph{Variables :} \csname alignat*\endcsname{2}} {\csname endalignat*\endcsname}


3

You can't do \begin{textbf} or \begin{emph} and you shouldn't do \begin{Large} either. You want \newcommand{\session}[1]{% \begin{center}\Large\itshape\bfseries \stepcounter{sessioncounter}% Session \value{sessioncounter}: #1% \end{center}% } in the preamble and use \session{Hello world} in the document.


3

Your definition matches the format of an environment, not a command. This is how environments are defined: \newenvironment{example}{<starting commands>}{<ending commands>} They are then used like this: \begin{example} <text> \end{example} But I think you want a command that takes one argument, as in this example. Also, ...


3

This is adapted from what I have used in the past (not sure where I got it from): Code: \documentclass{article} \usepackage{amsmath} \newcommand*{\QED}[1]{% \ifmmode% Check for math mode. \tag*{\fbox{#1}}% \else% {\rightskip\fill\parfillskip-\rightskip% \linepenalty100% \exhyphenpenalty0% ...


3

The idea is to add a conditional that's true when a proof starts and change the code accordingly: if the conditional is false, we're not nesting, so we set \qed@current to \qed@empty, otherwise we use the same mechanism as in the other answer. \documentclass{book} \usepackage{amsthm,xpatch} \makeatletter \let\qed@empty\openbox % <--- change here, if ...


2

I think it's better to use the \excludecomment macro provided by the comment package. This way you don't need to start and end comment environments from inside macros or environments of your own. \documentclass{article} \usepackage{ifthen} \usepackage{comment} \specialcomment{solution}{\textbf{Solution}\quad}{} \newboolean{iflecturer} ...


2

Here is one possibility, by redefining the way \descriptionlabel works at the beginning of every induction environment: \documentclass{article} \newenvironment{induction}[1] {\renewcommand{\descriptionlabel}[1]{\hspace\labelsep\normalfont\bfseries$#1$-induction, $##1$}% \begin{description}} {\end{description}} \begin{document} ...


2

You can obtain what you want and automatic numbering of items within enumerate-like environments, with enumitem: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{enumitem} \newlist{induction}{enumerate}{4}%% up to 4 levels for this new list \setlist[induction]{wide=0pt, leftmargin =3em} \setlist[induction, ...


2

\csname endalignat*\endcsname expands to the command \endalignat* that you can't normally type. So \foo here is a helper macro that makes the environment definition that you intended except that the command names are passed as arguments #1 and #2, then \expandafter is used to make the command names socthe construction is the same as ...


1

Not everything that's possible with word processing programs is necessarily good typography. Here's a version with exaggerated letter spacing. \documentclass{article} \usepackage{enumitem} \usepackage{showframe} % just for the example \newlist{mylist}{itemize}{1} \setlist[mylist]{ leftmargin=4cm,% adjust to suit labelwidth=4cm,% the same as leftmargin ...


1

Using the idea of @Harish Kumar i tried to implement something like this \documentclass{article} \usepackage{enumitem} \newlength{\fwidth} % Width of the `label column` \setlength{\fwidth}{2.5cm} % Fix width of label \newlist{mlist}{itemize}{1} \setlist[mlist]{leftmargin=*,labelsep=0pt} \newenvironment{mylist}[2][\fwidth]% ...


1

You can use the environ package instead of comment to discard the content of an environment. \documentclass{article} \usepackage{etoolbox} \usepackage{environ} \newtoggle{lecture} \NewEnviron{myitemize}{% \iftoggle{lecture} {\begin{itemize}\BODY\end{itemize}} {}% } \begin{document} \toggletrue{lecture} The environment is visible ...


1

\documentclass{article} \usepackage{color} \usepackage{expl3} \newcommand\gamediff[2][red]{\color{#1}{\underline{\color{black}{#2}}}\color{black}{}} \newsavebox\MBox \newcommand\gamediffeq[2][red]{{\sbox\MBox{$#2$}\rlap{\usebox\MBox}\color{#1}\rule[-1.2\dp\MBox]{\wd\MBox}{0.5pt}}} \ExplSyntaxOn \seq_new:N \g_crypto__gameseq_seq \tl_new:N ...


1

\documentclass{article} \usepackage{enumerate} \newcommand\newEnum[1]{% \newenvironment{enum#1}{\enumerate[#1.]}{\endenumerate}} \newEnum{1} \newEnum{a} \begin{document} \begin{enumerate} \item foo \item bar \end{enumerate} \begin{enum1} \item foo \item bar \end{enum1} \begin{enuma} \item foo \item bar \end{enuma} \end{document} However, using ...



Only top voted, non community-wiki answers of a minimum length are eligible