{environments} is for general questions related to (La)TeX environments. For questions about environment subcategories like {lists}, {quoting} environments, or {floats} use the appropriate tag instead.

learn more… | top users | synonyms (3)

5
votes
1answer
33 views

The Environ package misbehaviour on empty content

I have encountered a problem with the environ package. It returns a wrong \BODY value when the content of an environment is empty. Here is an example: \documentclass[12pt]{article} ...
8
votes
1answer
133 views

How to track a page change within an environment?

I'm trying to define an environment that can automatically detect when the material within it moves to a new page, reprint one of its arguments at the top of the new page, and change how it closes as ...
2
votes
0answers
69 views

using block environment for arabic/persian Beamer and right alignment

I have a problem with block environment in Beamer. I am using persian/arabic language. For the block environment, I want the title of the block and the text inside the block be aligned on the right ...
7
votes
1answer
147 views

Redefine block environment in beamer

I'm trying to redefine the block environment in beamer so that the itemize/enumerate bullets follow the color of block title instead of structure: \documentclass{beamer} ...
2
votes
1answer
64 views

Can the `verbatim` environment be used inside a custom environment definition?

I have the following code: \documentclass{minimal} \newenvironment{abc} {\begin{verbatim}} {\end{verbatim}} \begin{document} % This works. \begin{verbatim} abc \end{verbatim} % This does not ...
7
votes
2answers
150 views

A problem with environment starting macro

For some reason I want a macro \BeginControl such that \BeginControl{\environment} is equivalent to \begin{environment}. I have put together some code. It usually works but there is a problem with ...
2
votes
1answer
53 views

Why is my custom wrapfig environment messed up?

I want to create a wrapper environment for wrapfigure in order to locally set \initextsep to 0. I know, it could be done differently, but this code is exhibiting strange behaviour. It moves the figure ...
2
votes
1answer
32 views

foreach and renewcommand

I want renew a variable in a foreach loop, but my codes won't work. Please help! \documentclass{article} \usepackage{pgffor} \newcommand\tests{ \newcommand\mytext{aaa} \foreach \i in ...
2
votes
3answers
61 views

Suppressing vertical space between environments

I specified two environment in a LaTeX document to highlight different lines of codes: \newenvironment{code}{\color{blue}}{\ttfamily}{\par} \newenvironment{codegrey}{\color{grey}}{\ttfamily}{\par} ...
2
votes
1answer
62 views

Treat environment content as string, replace substrings and interpret afterwards

I would like to define an environment which "parses" its content and changes it before displaying it. An additional difficulty comes because I also need to replace whitespaces. The more flexibility ...
1
vote
1answer
154 views

How to learn LaTeX in the right way? [closed]

Many people always say that LaTeX is the best typesetting system which is flexible and powerful. For me, I have used LaTeX for one year already but I still have some problems with it. Let me talk ...
2
votes
1answer
109 views

\newenvironment does not work

I have created a new environment using this commands: \newenvironment{eqs} {\begin{subequations}\begin{align}} {\end{align}\end{subequations} } I would like to combine subequations and ...
28
votes
3answers
38k views

Example environment?

I was wondering if there is any formal environment for specifying 'examples' through out the text. If not, which environments do you recommend?
1
vote
1answer
36 views

font consistency in environment (theorem…) and in general text

I am using a template, and it uses the font \usefont{T1}{bch}{m}{n}\selectfont{}, the third font in the code and output, for the text in general. But this font is not used inside environments, like ...
5
votes
1answer
51 views

How to end a user-defined environment having conditional start definitions?

For silly example, the following user-defined environment initiates either the itemize environment or the enumerate environment, depending on the optional argument. But if the argument variable cannot ...
1
vote
1answer
72 views

Remove whitespace around own environment

Does anyone know how to remove the whitespace which is created by TeX everytime I use my own created environment? I tried the tricks with \ignorespaces and \ignorespacesafterend but that doesn't seem ...
2
votes
2answers
83 views

Definition of a macro with multiple arguments and usage of \csname

Why does the following code not work ? \Requirepackage{amsthm} \renewcommand\newtheorem[2]{% \NewEnviron{\csname #1\endcsname}[1]{% ##1 : \BODY } } I have seen examples of the use ...
15
votes
2answers
330 views

Environment to stack a word and a number

There is a requirement to write a list of words, underline each word and place a number centered below the line. Using the stackengine package I have prepared the following MWE. ...
3
votes
1answer
82 views

What to use for itemize/enumerate/description type question

I have a lemma in which I want to say something like this: Let f be a function which satisfies either (A) f=0 and f is continuous, or (B) f=1 and f is well-defined. Then f is good. ...
1
vote
1answer
37 views

Problems using hooks

I am trying to duplicate a document using hooks at the beginning and the end. Here is a minimal example of my problem : \documentclass{minimal} \usepackage{environ} \usepackage{forloop} %Repeat ...
4
votes
1answer
92 views

Blank left and right delimiters produce an unknown symbol

I recently compiled one of my files after updating my TeX distribution (including the unicode-math package, as I use the MinionMath font set) and noticed a strange error. In my file I used a cases ...
4
votes
1answer
66 views

How to condense environments and options to one environment?

In order to make grey boxes around code in my document I am using: \usepackage{listings} \usepackage{xcolor} %custom colours \usepackage{mdframed} %nice frames \definecolor{light-gray}{gray}{0.95} ...
0
votes
1answer
53 views

how to create a list for mdframed example boxs

So i found the question Make an Example and shaded box like in the book which fitted to my desires. I modified the box and counter so it fits to my whishes. (first number is the chapter second number ...
2
votes
1answer
32 views

Misplaced frametitle in new environment

In beamer, I defined a new environment for frame. My problem is, the frame title now comes along the text, instead of appearing at the top. See the working example. \documentclass[]{beamer} ...
0
votes
0answers
21 views

Call environment lstlisting without begin-end [duplicate]

I want to create a command for calling the lstlisting environment without the use of \begin{lstlisting}...\end{lstlisting}, i.e. I want to write something like \lst{text in enviromnent}. I have tried ...
0
votes
1answer
446 views

Making boxed “problem” environment and a solution environment [closed]

I'm trying to make a template for my homework. I've been using a modification of the Harvey Mudd homework class, but there are some things I don't really like about it (functional and aesthetic). ...
1
vote
1answer
36 views

Wrap single command as environment [duplicate]

I am trying to define a note environment, currently it is just a wrapper of \marginpar function like this: \newenvironment{note}{\marginpar}{} but \begin{note} Important Notes \end{note} will ...
1
vote
0answers
53 views

How to make a new figure environment that does additional stuff?

Currently I have a document in which most caption of figures and tables is placed in the margin, using mcaption. But for some figures and tables I need the full width (textwidth and margin). Both ...
4
votes
1answer
64 views

How to define a new left-aligned environment?

I am working on preparing a document in latex, and I need to define an new environment as follow: When the code is: \begin{IF} the sum of $a$, $b$, and $c$ is 10,\\ the product of $a$, ...
1
vote
1answer
43 views

Redefining an environment and summary box using grid and gridleno

This question is inspired by Gonzalo's great answer here concerning his creation of gridleno.sty to enhance the functionality of grid.sty. Ultimately I have two seemingly simple questions (please ...
2
votes
1answer
134 views

Shaded theoremstyle

I'm trying to create a theoremstyle whith a shaded background. As I already have a working preamble I'd like to change as less as possible. Previously I defined an own theoremstyle 'selfdefined' which ...
4
votes
2answers
87 views

Move tag next to equation in align environment

It's my first time asking here but I have got so much help from this site :D My particular case is that I need order and tag Maxwell's equations but I need set the tag in a particular location, just ...
1
vote
1answer
49 views

How to automatically escape special characters in your own environment?

I need to create my environment for examples of source codes. I want it to look like this: Code example: ------------------------------------------------ # This is the code example echo 'Hello' ...
33
votes
3answers
781 views

Do fontsize environments exist?

Without any doubt there are fontsize switches in the form of control sequences (described here for instance.) But, from time to time I ran into code examples where environment versions of those were ...
2
votes
0answers
34 views

(Is it wrong to) Use commands to begin and end equations (?) [duplicate]

I'm helping a professor write the second edition of his book, so I'm working with a lot of "old" code and bad practices. Something I've found is that he has defined macros for beginning and ending ...
2
votes
0answers
47 views

How do I make unruled footnotes within an environment?

I have a single environment, fancyfoot, in which I would like footnotes to have no rules. \documentclass{memoir} \usepackage{lipsum} \newenvironment{fancyfoot}{ \renewcommand{\footnoterule}{} ...
3
votes
2answers
41 views

How can I print beginning and end values of a counter within an environment?

I'm working on a formatting system for standardized tests. Within each section of a test, there are groups of consecutive questions that I might choose to contain inside an environment. ...
1
vote
1answer
37 views

Use macro as totcount counter name

In the top level of the document environment, a macro defined (using \def) can be expanded into the name of a totcount counter. This, for some reason, does not work inside an environment definition. I ...
2
votes
1answer
79 views

NewEnviron, \BODY and lstlisting [duplicate]

I was trying to understand egreg's answer to Hide content to show later, and I noticed that there were some problems when using lstlisting or tcblisting environments inside the solution environment ...
2
votes
1answer
116 views

Legrand Orange Book template Example colorbox from black to ocre

In the Legrand Orange Book template, I would like to change the begin and end of the Example Box color from black to ocre: and Here is the code from the structure.tex file where the example ...
4
votes
2answers
133 views

Is it possible to “scan” the text within an environment?

Say I have an environment env which is used like this: \begin{env} *Text* \end{env} Is it possible to "use" *Text* in the definition of the environment (top or bottom part) - similar as a ...
5
votes
1answer
443 views

TikZ Nodes in margin gets overwritten by page-wide tikz environments

I'm trying to improve the typesetting of openly licensed books created by my company. We do the typesetting of all our books with LaTeX. The design of these books requires coloured environments that ...
4
votes
1answer
222 views

converting documentclasses into environments: is it possible?

Rewritten question. For my phd-project i need to quote screenplays. I would like to keep the screenplay layout in my thesis. I know there is the document class called screenplay. Now i am wandering ...
10
votes
2answers
201 views

Strikeout all text, including enumerated lists

Is it possible to define an environment that strikes out all text, even in enumerated lists? I am basically trying automate what is currently being done manually in Microsoft Word. I have a body of ...
2
votes
3answers
2k views

Problems with environments in TeXStudio

This document \documentclass{article} \usepackage{amsthm} \newtheorem{lemma}{Lemma} \newcommand{\mycommand}{Here is the command} \begin{document} \begin{lemma} Here is the lemma \end{lemma} ...
4
votes
2answers
101 views

Compilable custom environment when in the body text becomes uncompilable when defined as a new environment

I attempted to make a table which has gray backgound cells except for the first column and the first row colored blue. The following code successfully generates the desired output (although I do not ...
1
vote
0answers
14 views

Is it possible to include a lstlisting code block inside an lstlisting? [duplicate]

I am trying to include a LaTeX code within an lstlisting. But the problem is that the LaTeX code includes an lstlisting, so the \end{lstlisting} within the included code is terminating the actual ...
0
votes
0answers
53 views

Predefining placement of figures and tables in custom package

I am trying to define figures in a new custom package using \newenvironment{name}{begin defs}{end defs} and minipage command (code is given below). if i create a \newcommand{\name}{defs} (named as ...
5
votes
1answer
137 views

What are the uses of being able to refer to an environment body by a macro?

The packages environ and newenviron both provide an alternative to the standard environment macros included with LaTeX. The main difference is that they make it possible to refer to the environment ...
3
votes
0answers
42 views

Extensions to the standard environment, what is out there?

\NewDocumentEnvironment from the xparse package allows accessing environment arguments also in the code that is supposed to go after the content. environ and newenviron allow referring to the ...