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 ...
Skillmon's user avatar
  • 56.2k
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 ...
egreg's user avatar
  • 1.1m
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 $...
David Carlisle's user avatar
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: \...
Alan Munn's user avatar
  • 213k
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} { \...
egreg's user avatar
  • 1.1m
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, ...
gz839918's user avatar
  • 1,689
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. ``...
John Kormylo's user avatar
  • 77.4k
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
Phil Hirschhorn's user avatar
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} \...
samcarter_is_at_topanswers.xyz's user avatar
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 ...
Vincent's user avatar
  • 19.4k
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 ...
egreg's user avatar
  • 1.1m
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 ...
muzimuzhi Z's user avatar
  • 25.5k
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 (...
wipet's user avatar
  • 69.5k
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} \...
FChris's user avatar
  • 187
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 ...
Skillmon's user avatar
  • 56.2k
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} { \...
egreg's user avatar
  • 1.1m
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 ...
egreg's user avatar
  • 1.1m
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 ...
Willie Wong's user avatar
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 ...
wipet's user avatar
  • 69.5k
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 ...
PDL's user avatar
  • 21
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. ...
gernot's user avatar
  • 48.3k
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 ...
Willie Wong's user avatar
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 ...
Steven B. Segletes's user avatar
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} ...
egreg's user avatar
  • 1.1m

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