6
votes
2answers
124 views

How to rewrite this command using \newenvironment?

I once defined a customized latex command, which works well. And now I would like to convert it into a latex environment using \newenvironment command. However, I failed after trying several ways. ...
10
votes
3answers
695 views

Found it tiring to type so many \begin and \end

Is there some way to get rid of the \begin and \end's? For example, I need to type a small matrix, but I should type \begin{matrix}...\end{matrix}. I tried to define a macro ...
1
vote
0answers
18 views

Custom environment shorthand for multiple environments [duplicate]

I am interested in doing something like the following. \documentclass{article} \usepackage{amsmath} \newenvironment{customeq}{\begin{equation}\begin{split}}{\end{split}\end{equation}} ...
4
votes
1answer
67 views

Redefining environment within a macro

Hel-lo, I am a LaTeX programming newbie. While formatting my document, I found that it will look nice if I can modify the theorem environment (with amsthm package). So I tried the following code ...
6
votes
3answers
168 views

Adding vertical space (\vspace) around custom environment

I have document with custom environment myenv which left margin is 4em. \documentclass{book} \usepackage{lipsum} \newenvironment{myenv}{ \setlength{\leftskip}{4em} } \begin{document} \lipsum[1-2] ...
1
vote
1answer
101 views

How to define a command that could generate similar environments just as \newtheorem does?

It's well known that the LaTeX built-in command \newtheorem could generate a series of the theorem environments that are similar: they share the same theme of layout style but differ in their name and ...
9
votes
1answer
105 views

Suggestions for an automatic taxonomy environment

Background In this site there are excellent examples of How to draw up a hierarchical tree diagram for taxonomic classification of several groups but often you must show only the position of a ...
4
votes
1answer
174 views

using fbox in a newenvironment [duplicate]

I am trying to write a new enviroment to add text into a \fbox, when I use \fbox on its own, it works quite nicely \fbox{\begin{minipage}{0.9\textwidth} does this work, I would love if it did ...
5
votes
0answers
46 views

What are the differences between creating a new macro command vs. a new environment? [duplicate]

For the purposes of collaboration, I want to create a number of short commands or environments that will color the text within its scope so as to identify the author. My first thought was to simply ...
2
votes
2answers
106 views

\begin{problem} analogue to \begin{proof}

I recently learned about \begin{proof} ... \end{proof}, which is a good environment to work in. My question is whether there exists a similar environment to state a problem, or whether I can write ...
1
vote
0answers
63 views

frame in NewDocumentEnvironment

With beamer frames, this does not work. \newenvironment{itemframe}[1]{ \begin{frame}{#1} \begin{itemize} }{ \end{itemize} \end{frame} } Adding fragile, environment=itemframe as an ...
3
votes
1answer
69 views

Using savebox around the BODY of environ

I tried to use a \savebox around the \BODY macro of \NewEnviron. Can I keep the linebreaks somehow (they are gone, in the MWE)? \documentclass{article} \usepackage{environ} \newsavebox{\mybox} ...
0
votes
0answers
33 views

Putting itemize environment in a tabular environment [duplicate]

I have a macro that makes an itemize environment. When I tried to use the macro in a tabular environment, I have this error message. ERROR: LaTeX Error: Something's wrong--perhaps a missing \item. ...
0
votes
2answers
50 views

Environment inside a command

My code \documentclass[a4paper,12pt,twoside]{article} \usepackage[english]{babel} \usepackage{amssymb} \usepackage{amsmath} \newcommand{\QUE}[1]{% {\bf Question\# 1 }: #1 }%end QUE \raggedbottom ...
4
votes
1answer
163 views

Combining newenvironment, quote and lstlisting (mcode)

I am trying to combine various packages and commands with PdfLaTeX (through MikTex on MS Windows), including newenvironment, quote, mcode and lstlisting, to create an environment to define multiple ...
3
votes
2answers
71 views

Why linebreaks break the line height within certain environments with size-changing macros?

Why linebreaks break the line height within certain environments with size-changing macros? I'm trying to understand what's the difference between these three approaches: \newenvironment between {} ...
3
votes
1answer
77 views

How to create nested custom environment with different kind of frames?

So before I write ten pages describing what I'm looking to do, I made a small mock up: I had something like this in mind: \begin{mybox}[Name] \begin{syntax} here comes source code \end{syntax} ...
11
votes
2answers
159 views

How to create a macro “environmentally-dependent”

Yesterday I was reading the etoolbox documentation where there are defined some new document commands such as: \Before<Begin/End>Environment{<envir>}{<code>} % ...
6
votes
2answers
119 views

Using an expanded macro for optional environment argument

I'd like to open an environment, passing the content of a macro to the optional arguments. Up to now I tried different approaches using \expandafter, however I could not get the expected behaviour. ...
2
votes
1answer
68 views

How to remove \BODY defined in the algorithmic package?

The algorithmic package defines a command \BODY which evidently clashes when used in conjunction with the environ package. More specifically, LaTeX failes to compile when an algorithmic environment is ...
5
votes
1answer
44 views

How make \parshape declared inside an environment to apply the next paragraph outside the environment?

I'm trying to do something like the MWE below: \documentclass{article} \usepackage{lipsum} \newenvironment{myenv}{% \parshape = 4 0pt 0.5\textwidth 0pt 0.5\textwidth 0pt 0.5\textwidth ...
4
votes
3answers
102 views

Creating an environment that uses macros

I have a macro that requires some setup code before being called : \documentclass{minimal} \usepackage{color} \begin{document} % some setup code \colorbox{green}{This is green.} % some cleanup code ...
3
votes
1answer
454 views

\newenvironment where all text is typewriter (like \texttt)

I'd like to have an environment that encloses all its content into the typewriter font as \texttt{} does. However, I do not want to use \texttt{} but an own environment, e.g. \begin{allintypewriter} ...
4
votes
1answer
166 views

Making a class to generate colored tables with a predefined layout

This is a follow-up question in which I asked how to define classes with \newcommands into \newenvironments, and I had some good answers to this particular issue. However, the problem that I have ...
5
votes
2answers
85 views

Macro defining environment

How to write an environment such that \begin{comment} Bla, bla. \end{comment} produces no output, and instead defines a macro \@comment whose replacement text is everything that is inside the ...
5
votes
2answers
271 views

TikZ: Using optional arguments in after part of \newenvironment*

How can I pass the optional arguments to a node being drawn in the after part of a \newenvironment*? In the before part this is easy since I can simply use #1. I tried using \edef, but that ended up ...
9
votes
2answers
115 views

How to improve maintenance of starred/non starred versions of commands or environments

All documentations I've read about starred/non starred versions of commands recommend more or less the following way of doing (following for instance the UK List of TeX FAQ): ...
2
votes
1answer
121 views

Using data from tabulary to typeset columns

While trying to write a better answer to this question, I've made several (probably quite bad) attempts to use the tabulary environment to typeset paragraphs to try to in some way be able to split a ...
4
votes
1answer
214 views

Converting string to number

I am trying to write an environment which provides (some of) the functionality parallel environment through tabular syntax so that the following two code snippets would give equivalent results: ...
16
votes
2answers
217 views

Duplicating Environments

When I want to globally modify a command in my document, I will often use a duplicated version of the original in the stencil, with the help of the \let macro. For example, if I wanted to do ...
8
votes
3answers
111 views

How can I collect the contents of a LaTeX environment in a macro without the grouping?

It's a bit of a long story as to why I need to do this, but please bear with me. I have a fairly complicated custom class which expects documents to begin with a command: \coverandabstract{Abstract ...
3
votes
1answer
81 views

Change \newcommand behaviour based on the environment

I'd like to define a command \Lm, such that if used in a maths environment it is replaced with \mathcal{L}, but when used outside of the maths environment it would be replaced with $\mathcal{L}$. This ...
4
votes
4answers
680 views

Defining a new environment extending a verbatim environment

Why is it not possible to define a new environment that extends a verbatim environment? Consider, e.g.: \documentclass{article} \newenvironment{myverbatim}{\tiny\begin{verbatim}}{\end{verbatim}} ...
2
votes
1answer
117 views

using a restatable before it is stated

This question is related to the question at Recalling a theorem, which uses the thmtools and thm-restate packages and the restatable environment to define a theorem that can be re-stated later on. Is ...
4
votes
1answer
125 views

How to change an environment into newcommand?

Suppose that I want to create a new command named step, which functionally add Step 1., Step 2., and so on in the proof. This can be done by: \newcounter{stepnum} ...
6
votes
2answers
148 views

Delaying command expansion that appears in \begin handler until \end handler executes

I have a custom environment for handling a code interface declaration that is specified as: \begin{decl}{FOO} \param{in}{bar} the bar input parameter \param{out}{baz} the baz input parameter ...
3
votes
1answer
121 views

How can I define a new environment which limits the scope of \newtheorem commands?

I am attempting to make an environment out of the command given in one of the answers to this question: Customizing theorem name. \documentclass{article} \usepackage{amsmath} \usepackage{amsthm} ...
10
votes
5answers
423 views

How to create a “delay expansion” environment?

I don't want to use the following \begingroup \edef\next{\endgroup \noexpand\const{Xp}{\X(tp)} \noexpand\const{Yp}{\Y(tp)} \noexpand\const{Xf}{\X(tf)} \noexpand\const{Yf}{\Y(tf)} ...
4
votes
1answer
135 views

Class Design: Environment vs. Macro

I have seen What are the consideration when choosing either newcommand or newenvironment? but I think this is a little more specific. If it's a duplicate, then so be it. If the second part of the ...
13
votes
4answers
262 views

What are the consideration when choosing either newcommand or newenvironment?

The first time I learnt LaTeX, I thought \newcommand properly fits for inline mode and \newenvironment for displayed mode. Later I noticed it is not correct. So the question is What is the rule of ...
7
votes
1answer
394 views

Define a command for italic, bold and centered title inside a quote

Inside my quote, I have a bold, italic and centered header. How can I define a command so that I can typeset this text all in one go? I tried: ...
2
votes
2answers
92 views

Add parameter to existing command produces error

I have this command in a template given by my prof \newcommand{\homeworkProblemName}{}% \newcounter{homeworkProblemCounter}% \newenvironment{homeworkProblem}[1][Problem ...
3
votes
1answer
345 views

Create an environment like the `checkboxes` in exam.cls

I am having trouble on how will i create something like the checkboxesor oneparcheckboxes environment in exam.cls. The only difference is that since the checkboxes gives circle, i'd like to create ...
14
votes
1answer
322 views

Is there a way to have an “empty” environment to merely limit scope of declarations?

I am fairly new to LaTeX, so I apologize if this is a beginner question, but I have not found a good way to query for it otherwise. I have observed that when I use an environment like ...
16
votes
6answers
485 views

A new environment to decide dynamically which commands to run?

I am having some user defined commands defined and used in my latex document. I need a way to check whether any of the commands is used. I want to make decisions based on the argument used in the ...
9
votes
1answer
206 views

how to redefine \begin{align*} … \end{align*} to \begin{eqnarray*} … \end{eqnarray*}

Scientific word insists in generating displayed math using \begin{align*} ... \end{align*} and htlatex has a bug in that it does not generate bit mapped images in this case. The fix that I found ...
5
votes
2answers
293 views

Multiple split equations

I find myself again and again using a combination of the gather and aligned environments. So it would be nice to not have to write so much. In particular, it is often only clear after writing the ...
19
votes
7answers
739 views

How to create a command that automatically escapes curly braces?

How could I create a command that will automatically escape all curly braces within the current environment? For instance, I would like a command (or environment, I suppose) that allows me to write ...
4
votes
1answer
582 views

lstlisting in a newenvironment

I have a problem with the lstlisting package. I want to define an \newenvironment with one obligatory parameter, which will be the caption name for the lstlisting. I will also have other lstlisting ...
0
votes
0answers
76 views

Is there a way I can get the LaTeX environment? [duplicate]

Possible Duplicate: Where do I find out how a command/environment is defined? Is there a way I can get LaTeX environment for a given set-up? For example I want to get the value of some ...