Tag Info

Hot answers tagged

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}}] ...


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} ...


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

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 ...


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 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

\newenvironment{graf}[1][]{}{} generates the error ! LaTeX Error: Command \graf already defined. Or name \end... illegal, see p.192 of the manual. You really don't want to ignore that error. Call your enviornment something else, otherwise you would be redefining \endgraf (which would be bad).


2

Update Based on revised MWE. Unfortunately I don't know why this problem occurs. But, one way to proceed is to eliminate the warning of missing list items as per How to make itemize/enumerate/description environment robust to missing \item elements? Code: Suppress Missing Item Error \documentclass{article} \usepackage{environ} %% Allow for lists to ...


2

I changed the \renewenvironment line to \renewenvironment{solution}{\solutionnew}{\endsolutionnew} You also seemed to be missing the ending part of the environment definition in solutionnew which I just added as a {}. Perhaps a macro form would be more suitable. I also recommend making the \marginpar ragged. See original answer here and FOLLOW UP ...


2

It is to do with the way tabularx deals with its argument. The package environ provides a work around for such situations. Instead of \newenvironment you say \NewEnviron{myenv}{start code \BODY end code} Then \begin{myenv} mybody \end{myenv} will run the contents of myenv with \BODY replaced by mybody. In your case the relevant definition ...


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 ...


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, ...


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

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]% ...



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