8
votes
Accepted
Why isn't my environment restored?
You should use \NewEnvironmentCopy and \DeclareEnvironmentCopy instead of \let to save and restore an environments definition. That way you don't need to know how the environment was originally ...
5
votes
Why isn't my environment restored?
Skillmon has explained how to fix, here's why your code can't work.
Generally speaking \NewDocumentEnvironment{foo} still defines \foo and \endfoo, but these are just the surface macros.
Indeed, you ...
4
votes
The display math mode and the `center` environment
You could simplify your example to
\documentclass{article}
\begin{document}
\mbox{$ \times $}
\mbox{$$ \times $$}
\mbox{\begin{center} x \end{center}}
\end{document}
Where you get no error from $...
3
votes
Accepted
Custom Environment with Parentheses around Optional Parameter
Optional arguments are usually introduced with [...], and since this is an optional argument to the environment, I think it makes sense to use that syntax. So here's a version that does exactly that:
\...
3
votes
Accepted
Create a new environment that can switch between center, flushleft, flushright from based on a parameter
Here's with expl3; you can use l, c or r besides left, center or right.
\documentclass{article}
\usepackage{lipsum} % for mock text
\ExplSyntaxOn
\NewDocumentEnvironment{withalignment}{m}
{
\...
3
votes
Accepted
How to parse square bracket arguments into several curly braced arguments?
Under the hood, options to a tcblisting are processed as PGF Keys. The optional argument #1 passes its contents to the code environment, which means that we can pass in our own module of PGF Keys, ...
3
votes
Why isn't my environment restored?
This demonstrates the use of two differnnt names. I follow the rule "\def once, \let repeatedly."
\documentclass[]{article}
\NewDocumentEnvironment{mydummyenv}{m}{I will print #1 before. ``...
2
votes
\AtBeginEnvironment does not work for the questions environment in the exam class
Just add the command
\renewcommand{\questionshook}{\setcounter{question}{4}}
to your preamble instead of trying to use \AtBeginEnvironment
2
votes
Accepted
How to make minted work inside custom environments?
Use a custom environment and not a macro:
% !TeX program = txs:///arara
% arara: pdflatex: {synctex: on, interaction: nonstopmode, shell: yes}
\documentclass{beamer}
\usepackage{minted}
\...
2
votes
Create a new environment that can switch between center, flushleft, flushright from based on a parameter
Still not very elegant with all the \ifs, but it works.
\documentclass{article}
\newcommand*{\alignment}{}
\newenvironment{withalignment}[1]{%
\renewcommand*{\alignment}{#1}
\if\alignment c
...
2
votes
Accepted
What is the correct/best way to control the optional arguments of an environment so they can be easily edited later
The attempt with
\def\pythonarguments{breaklines, showspaces}
\begin{minted}[\pythonarguments]{python3}
isn't going to work, because the argument is not expanded looking for key-value options.
You ...
2
votes
Accepted
Fully expand an argument of a newenvironment created with expl3
Changes I made:
[required] In defining \vincent_alignment:n, \str_case:nn is replaced with \str_case:en
[optional] In defining withalignment environment, an \exp_args:Ne is added in front of \begin ...
2
votes
Figures not indenting with a custom environment
When TeX interprets \noindent\par in vertical mode then it opens the paragraph with no indentation box (\noindent) and it immediately closes this empty paragraph (\par). The paragraph has no lines (...
2
votes
Custom Environment with Parentheses around Optional Parameter
Alan Munn already beat me to it and probably has a nicer solution. But since I learned that myself just now, here is an alternative which uses the environ package.
\documentclass[10pt]{article}
\...
2
votes
Accepted
Expand macro in options list for environment
If all your key=value contents can be subject to full expansion you could use \expanded to expand it before the tblr-environment reads it. You should then protect the \begin from expanding (using ...
2
votes
Accepted
How convert equation environment to dmath environment automatically?
First of all, you want dmath, not dmath*.
\documentclass[12pt,notitlepage]{article}
\usepackage{amsmath}
\usepackage{breqn}
\ExplSyntaxOn
\RenewDocumentEnvironment{equation}{b}
{
\...
1
vote
Figures not indenting with a custom environment
Use enumitem features for the lists, not hand numbering. Don't load also enumerate, it's not compatible with enumitem.
Also, avoid [H]. With a minipage and \captionof you get the same and you can ...
1
vote
Figures not indenting with a custom environment
I admit I am not 100% sure what your question is. The standard proof environment does not indent anything. The word "Proof" appears left justified with no indentation. However, the soln ...
1
vote
Expand macro in options list for environment
The same diagram can be achieved using TeX primitives only. Creating such macros is much more fun.
\newdimen\bw \bw=1.8em
\def\dashrule{\lower4pt\vbox to15pt{%
\cleaders\vbox{\kern.5pt\hrule ...
1
vote
How to make environments appear by using code abbreviations?
You don't need to 'reinvent the wheel' here. Texmaker has Alt+Shift+M to insert a displayed equation environment, Ctrl+Shift+M for inline maths, Ctrl+Shift+L/R for left/right delimiters, and there are ...
1
vote
Accepted
Demoting unnumbered section using newenvironment not working for subfile
I'm not sure I fully understand the constraints yet, but here is a first try, as a basis for discussion
Put the definitions into the preamble of the mainfile, to make them accessible to the subfiles.
...
1
vote
The display math mode and the `center` environment
Actually, all you need to do is to transform your input structure to the input structure that moodle expects. Here I am assuming that your input data always have the structure
\begin{ex}
Question ...
1
vote
The display math mode and the `center` environment
As I noted in a comment, avoid \[..\] (and $$...$$) in this context and instead use $...$. Use \centering instead of the center environment. Thus, \centering $...$ will give a centered equation (you ...
1
vote
Accepted
How to make new environment using an existing environment? File ended while scanning use of \FancyVerbGetLine
You need to add \VerbatimEnvironment. Not really well documented…
\documentclass[12pt,titlepage]{article}
\usepackage{fancybox,fancyvrb,xcolor}
\usepackage[listings,skins,breakable,xparse]{tcolorbox}
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
environments × 3151macros × 419
theorems × 153
tables × 145
spacing × 141
lists × 103
tcolorbox × 103
equations × 95
beamer × 93
math-mode × 93
listings × 89
tikz-pgf × 86
counters × 80
conditionals × 79
align × 76
enumerate × 73
formatting × 72
numbering × 72
floats × 71
page-breaking × 68
cross-referencing × 67
indentation × 66
verbatim × 66
optional-arguments × 60
errors × 59