# Tag Info

13

The macro \newenvironment{foo} defines the two macros \foo \endfoo not \beginfoo. Rather than undefine spacing, you could simply make it a noop: \renewenvironment{spacing}{}{} This is preferable because it will keep track of nested environments.

10


8

The problem is that you have to define \@currentlabel to give the right value to your \label. So, after assigning the new value to the counter entryc through \refstepcounter, you need to add \protected@edef\@currentlabel{\thetheorem} (in this case probably \def\@currentlabel{\thetheorem} is enough). In other words, change the definition of your environment ...

7

You had defined \subsection in terms of itself which would have been an infinite loop, but you also used a command \start that is undefined. You intended something more like this: \documentclass[11pt]{article} \usepackage{multicol} \let\origsubsection\subsection \renewcommand{\subsection}[1]{\end{multicols}\origsubsection{#1}\begin{multicols}{2}} ...

7

You can do it, but I wouldn't recommend it. Look at the result and judge for yourself. \documentclass{article} \usepackage{enumitem} \usepackage{lipsum} % just for the example \newlength{\jeroenlen} \newenvironment{example} {\settowidth{\jeroenlen}{\textbf{Example:}}% \begin{description}[leftmargin=\jeroenlen,labelwidth=0pt,labelsep=0pt] ...

7

this example illustrates what i meant by "cloning" the amsthm proof environment. it retains the ability to use \qedhere to "move the end-symbol up" when the environment ends with a list or display math. \documentclass{article} \usepackage{amsthm} \makeatletter \providecommand{\examplesymbol}{\ensuremath\clubsuit} ...

7

If you're sure that every \\ in the environment has to be replaced, you can do it with xstring: \documentclass[a4paper,10pt]{scrartcl} \usepackage{amsmath,amsfonts,amssymb} \usepackage{environ,xstring} \NewEnviron{OptEnv}[1]{% \noexpandarg % don't expand arguments % with \expandafter get the expansion of \BODY ...

6

Verbatim environments are very special, and generally resist being the arguments of macros, which is effectively what you are doing when you try to put a verbatim environment inside another environment definition. For more details on this problem, see the UK TeX FAQ entry on the topic. Instead, what you can do is hook into the beginning of the verbatim or ...

6

Your \ve is essentially a version of \boldsymbol in most cases \bm is more efficient. However here I think you just want to declare a bold math italic alphabet: \documentclass{article} \usepackage{amsmath} \DeclareMathAlphabet {\mathbi}{OML}{cmm}{b}{it} \def\inv{^{-1}} \begin{document} \begin{equation*}\mathbi{ ...

6

You were nearly there, but the setting isn't trivial enough for trivlist, you want to use list \documentclass[12pt]{article} \usepackage[margin=1in]{geometry} \usepackage{amsmath,amsthm,amssymb} \newenvironment{question}[2][Question]{\begin{trivlist} \item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}} ...

5

The simplest solution is to define a wrapper environment such as \newenvionment{qn}{\par\noindent\begin{minipage}{\linewidth}{\end{minipage}\par} then use \begin{qn} \begin{question} Why? \end{question} \begin{answer} I don't know! \end{answer} \end{qn}

5

You need to use a "switch", achieved by issuing \bfseries at the start of the environment (say boldenv): \newenvironment{boldenv} {\bfseries}% \begin{boldenv} {}% \end{boldenv} The scope of this switch is limited to the environment, since \begin{boldenv} ... \end{boldenv} naturally forms a group. Also, italicized text inside this environment will ...

5

There is no environment tiny. There is a command \tiny. The same can be achieved with \bfseries: \newenvironment{foo}{\bfseries}{} – I think it's important to mention a fact which is mostly unknown: Don't use font commands as environments. Explanation: Let me start with a small example and the unwanted output: \documentclass{article} ...

5

As it says in the tabularx doc, the principal restriction on the \tabularx \endtabularx form is that \endtabularx is the first token in the end code. So the behaviour you see is documented feature, not a bug. However you could do: \documentclass{article} \usepackage{array} \usepackage{tabularx} \makeatletter \newenvironment{mytable}{% ...

5

You're missing \usepackage{amsthm}. I'd improve the definition, though, with enumitem instead of enumerate: \documentclass[11pt]{article} \usepackage{amsthm,enumitem,xcolor} \usepackage{mdframed} \definecolor{lightgray}{gray}{0.9} \newtheorem*{hulprule}{Rule settings} \newenvironment{drule}[3] {\begin{mdframed}[backgroundcolor=lightgray]% ...

5

Here is an idea: a three-part environment called Article, whose only (mandatory) argument is the date (specified as {<day>}{<month>}{<year>}). To start the Review part, simply use my \review macro. To start the To do part, simply use my \todo macro. It may be wise to rename those macros to avoid clashes with existing macros; for instance, ...

4


4

If you encase \BODY in a top-aligned, left-justified array environment, there's no further need to provide & alignment indicators: \documentclass[a4paper]{scrartcl} \usepackage{amsmath,amsfonts,amssymb,environ} \setlength\textwidth{3in} % just for this example \NewEnviron{OptEnv}[1]{% \begin{align} \min\ & #1 \\ \text{s.t.\ } & ...

4

hacking a bit into amsmath one can avoid loading further packages: \documentclass[a4paper,10pt]{scrartcl} \usepackage{amsmath,amsfonts,amssymb} \usepackage{environ} \makeatletter \NewEnviron{OptEnv}[1]{% \def\Let@{\def\\{\math@cr &}}% \begin{align} \text{min. } & #1 \math@cr \text{s.t. } & \BODY \end{align} } \makeatother ...

4

You can try defining a new theorem style: \newtheoremstyle{algo}% <name> {\topsep}% <space above> {\topsep}% <space below> {\itshape}% <body font> {}% <indent amount> {\bfseries}% <theorem head font> {}% ...

3

This is a more proper way to do it: \documentclass[a4paper,12pt]{article} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage{amssymb,amsmath,amsthm, mathtools} \newtheorem{theorem}{Theorem} \DeclarePairedDelimiter\norm\lVert\rVert \begin{document} \section{Mathematical Methods} \begin{theorem}[Placheral's Theorem] \begin{equation*} ...

3

The following MWE uses environ to define the exercise environment and then condition on whether or not to set its contents (\BODY). The condition is set to true at the start of bank, and set to false after setting the first \BODY. \documentclass{article} \usepackage{environ}% http://ctan.org/pkg/environ \newif\iffirstexercise% Condition for first exercise ...

3

\documentclass{article} \newenvironment{example} {\textbf{Example:}\begin{minipage}[t]{0.8\linewidth}\begin{itemize}} {\end{itemize}\end{minipage}} \begin{document} \begin{example} \item These are first examples. \item Second examples. \item And more. \end{example} \end{document}

2

Here's a way to do it with expl3; we check whether the first key is in the allowed list; if it isn't a warning is issued. \documentclass[10pt]{article} \usepackage{xparse} \usepackage{tcolorbox} \tcbuselibrary{listings,breakable,skins} \tcbset{ above/.style={colback=lightgray,colbacklower=white,listing and text,center lower}, ...

2

This shows how to do it in both macro (\notes) and environment (\begin{Notes}) forms. EDIT: Thanks to jfbu for the proper syntax that allows one to avoid environment nesting. \documentclass{article} \newsavebox{\mybox} \newenvironment{Notes} {\begin{lrbox}{\mybox}\begin{minipage}{0.9\textwidth}} {\end{minipage}\end{lrbox}\fbox{\usebox{\mybox}}} ...

2

You can use the QED mechanism that amsthm provides: define an appropriate symbol, push a QED at the beginning of the theorem, pop it at the end. You can then put \qedhere somewhere if you need the marker earlier, and the final pop will then do nothing. \documentclass{book} \usepackage{amsthm} \parindent0pt \newcommand{\thmsymbol}{$$\diamond$$} ...

2

although it's not possible to be sure what is really meant, without a compilable example, this sounds like the align and equation environments are set without any text between, like this: \begin{align} ... \\$$...$$\end{align} $$...$$ this isn't recommended. instead, it's possible to nest an align group within gather: ...

2

Idea is the same as in the other answer, however, the support for the starred varian and the optional argument was added: \makeatletter \let\subsection@old\subsection \def\subsection@pre{\end{multicols}} \def\subsection@post{\begin{multicols}{2}} \newcommand\subsection{\@ifnextchar*\subsection@star\subsection@nostar} ...

2

Use \itemindent=0pt If you don't want the quotations to be flush with the right margin, remove \rightmargin=\leftmargin. \documentclass{scrbook} \makeatletter \renewenvironment{quotation} {\list{}{\listparindent=1.5em \itemindent=0pt \parsep\z@ \@plus\p@}% \item\relax} {\endlist} \makeatother \begin{document} This is ...

2

\documentclass{scrbook} \begin{document} \makeatletter \renewenvironment{quotation} {\list{}{\listparindent 1.5em% %\itemindent \listparindent %\rightmargin \leftmargin \parsep \z@ \@plus\p@}% \item\relax} {\endlist} \makeatother This is normal text. ...

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