Skip to main content

New answers tagged

2 votes
Accepted

How to reference tcolorbox title

(Disclaimer: I wrote the package, keytheorems, used in this answer.) You should either use tcolorbox's built-in theorems library, or you can use the package keytheorems which uses amsthm under the ...
mbert's user avatar
  • 5,016
1 vote

Dynamically subtract space to make two tcolorbox environments continuous

It is not clear from the example code how the problem manifests itself. A few points: It is not elegant to create two (theorem-)environments for the same thing. The idea of ​​LaTeX is that the ...
cis's user avatar
  • 9,087
1 vote

Hide custom environment content based on boolean

A simpler answer with xparse and booleans, it can be nested, and no expansion problems \documentclass{article} \newif\ifshow \NewDocumentEnvironment{testenv}{ +b }{\ifshow#1\fi}{} \begin{document} \...
A. Marchand's user avatar
1 vote

How to start itemize on same line as text?

I don't think this is still relevant, but someone I know had the same question as you. After testing egreg's answer in an existing file where I had already defined an other "Example" ...
PseudoMagnifique's user avatar
3 votes
Accepted

Custom counters and environments in latexml

This is a known issue with \refstepcounter. The best solution is if you can employ something that can be labeled, such as an something using amsthm. You can also refer to this discussion.
Teepeemm's user avatar
  • 7,300
3 votes

How to create a custom environment in LaTeX for a specific type of content?

You can use \newenvironment to create custom environments: \documentclass{article} \newenvironment{reference}{% % at the start of the environment \bfseries }{% % at the end of the environment } ...
samcarter_is_at_topanswers.xyz's user avatar
0 votes

How to put global variables in environments?

I'd exploit property lists. \documentclass{article} \ExplSyntaxOn \NewDocumentCommand{\definevars}{mm} {% #1 = tag, #2 = data \manrique_var_define:nn {#1} {#2} } \NewExpandableDocumentCommand{\...
egreg's user avatar
  • 1.2m
1 vote

Automation of custom tables

With the tabularray package, you could use the \NewTblrEnviron macro to create a new tabular environment: \documentclass{article} \usepackage{tabularray} \NewTblrEnviron{mytable} \SetTblrInner[...
samcarter_is_at_topanswers.xyz's user avatar
1 vote
Accepted

Automation of custom tables

The code below loads the environment's contents and massages it. \documentclass{article} \usepackage[table]{xcolor} \ExplSyntaxOn \NewDocumentEnvironment{mytable}{O{\rowcolor{blue!30}}mb} {% #1 = \...
egreg's user avatar
  • 1.2m
2 votes

Automation of custom tables

With {NiceTabular} of nicematrix. \documentclass{article} \usepackage{nicematrix} \NewDocumentEnvironment { mytable } { O { } m O { } } { \begin{NiceTabular}{#2}[hlines,#1,#3] \RowStyle[...
F. Pantigny's user avatar
  • 43.8k
1 vote
Accepted

Hook that executes a verbatim environment from fancyvrb

(In the question it is said that solutions are to work with older LaTeX releases, too. So with this answer neither xparse nor expl3 was used although this might have made the task considerably easier. ...
Ulrich Diez's user avatar
  • 30.1k
0 votes

Conditional environment using package option

I ended up using both answers to put something together that fits what I want to \ProvidesPackage{solutions} \newif\ifsolutions \solutionsfalse % If solution is false the environment should blank ...
aram's user avatar
  • 279
2 votes

Conditional environment using package option

This is similar to Skillman's answer in that it uses \NewDocumentEnvironment and \colorbox. Since questions are usually typeset as lists, however, this tries to adapt to an enumerate or itemize ...
cfr's user avatar
  • 211k
4 votes
Accepted

Conditional environment using package option

Based on \NewDocumentEnvironment, \colorbox this is rather straight forward. Please keep in mind that \colorbox doesn't allow page breaks inside your solutions. \documentclass[]{article} \begin{...
Skillmon's user avatar
  • 63.1k
10 votes
Accepted

What does the \end mean in LaTeX's environment?

\end in latex is unrelated to the \end primitive described in the TeXBook. It is essentially \def\end#1{\csname end#1\endcsname\endgroup} This means that \end{foo} will execute \endfoo if it is ...
David Carlisle's user avatar
4 votes
Accepted

Package with environment that changes according to option

You need \ProcessOptions\relax to handle package options. \ProvidesPackage{solutions} \newif\ifsolutions \solutionsfalse \DeclareOption{solutions}{\solutionstrue} \DeclareOption{nosolutions}{\...
ljguo's user avatar
  • 1,920

Top 50 recent answers are included