Tag Info

18

The fellowship of \newenvironment and \renewenvironment commands Yes, \renew... will erase or redefine the previous definition (or eject an error message, if this has not been defined before.) In many cases it's more suitable to make a wrapper environment, which does not attack the original environment. \newenvironment{foo}{% %startup code, i.e the ...

11

The arc starts at (0, 1.2\@SizeOfCirc), which is above the + sign. As you want it to start below the +, simply change the arc to start at (0, -1.2\@SizeOfCirc). This gives the following result: To position the symbol such that the + is aligned correctly, you'll have to change the baseline option of \tikz to ...

9


7

Similar to hbaderts' but with a bit of extras (e.g., \DOTSB for correct autopositioning of \dots, usage of pgfmath macros to calculate the width, etc.) \documentclass{scrartcl} \usepackage{mathtools,amssymb,lmodern,tikz} \usetikzlibrary{arrows,bending} \newcommand*\carr[1] {\DOTSB\mathbin{\mkern2mu\tikz[x=1ex, y=1ex, line width=.1ex, line cap=round, ...

7

It is possible to wrap the question environment in a \tcolorboxenvironment redefinition. \documentclass{memoir} \usepackage{graphicx} \usepackage{exsheets} \usepackage[most]{tcolorbox} \begin{document} \tcolorboxenvironment{question}{colback=yellow} % 2nd arg is for tcolorbox options. \begin{question} Exercise text in a box \end{question} ...

6

Maybe you can use something based on Tikz. Option 1: The following is based on Gonzalo Medina's answer: \documentclass{article} \usepackage{tikzpagenodes} \usetikzlibrary{patterns} \usetikzlibrary{calc} \makeatletter \tikzset{% remember picture with id/.style={% remember picture, overlay, save picture id=#1, }, save picture ...

4

FWIW, in ConTeXt, the \overstike macro works well with enumerated lists. Here is an example: \starttext \overstrike{ \startitemize[n] \item \input ward \startitemize[i] \item \input zapf \stopitemize \item \input tufte \stopitemize} \stoptext which gives

4

I've just (2015/07/04) sent an update of exsheets to CTAN which allows the following (recommended) solution: \SetupExSheets{ question/pre-hook = \begin{tcolorbox} , question/post-hook = \end{tcolorbox} } The update should be available in a few days in TeX Live and MiKTeX. If you don't want to wait: the updated version (v0.19) is also available here: ...

4

New solution answering the question You want to build headings to your problems and their parts using information appearing later in the document. The obvious way to do this is using \label and \ref but as you want to do this behind the scenes the label names need to be generated dynamically. Dynamic labels for cross-referencing Below I have defined two ...

4

I do not know many cases (in fact none) where \makeatletter...\makeatother inside of macro is useful. In this case, it would prevent the correct expansion of the \@item etc. macros, and \apptocmd is applied to \item etc. \documentclass{book} \usepackage{enumitem} \usepackage{etoolbox} \usepackage[colorlinks]{hyperref} \makeatletter ...

4

The documentation is referring to a case such as \documentclass{article} \usepackage{etoolbox} \newenvironment{foo}[1]{}{} \AtBeginEnvironment{foo}{\newcommand\baz[1]{begin hook: #1}} \begin{document} \begin{foo}{bar} \baz{Lorem} ipsum dolor sit amet. \end{foo} \end{document} where we don't need to double the # tokens in the definition of \baz. ...

4

I've corrected the code so that it does what you want. However I also propose another similar environment, that I've called fboxedtxt, based on the framed package, which has the advantage to break across pages if necessary. Also, if required, it's not too difficult to modify the code to obtain coloured frames and/or shaded environment. ...

4

Using the powerful tikz package, we can define a \newcommand with three arguments as follows: \createtable{<# Questions>}{<# Columns>}{<Table caption>} like this: \documentclass[12pt,a4paper]{article} \usepackage{tikz,xcolor} \usetikzlibrary{calc} \begin{document} \newcounter{xy} \definecolor{Qcolor}{HTML}{EFEFEF} ...

3

Use the environ package instead to capture the body of the environment so as to avoid problems with the \colorbox opening in the begin part and closing in the end part of a standard \newenvironment: \documentclass{article} \usepackage[table]{xcolor} \usepackage{environ} \definecolor{tabularbg}{gray}{0.8} \definecolor{tabuline}{named}{white} % whiten the ...

3


3

Like this: Well, layers work only inside a single tikzpicture environment, and drawing more than one thing on the main layer is impossible. So, drawing takes the natural order in which the commands have been written; here you enter the markup for the marginbox, then the markup for the page-wide environment, so the latter covers the first. The solution I ...

3

You don't want a command name for the name of an environment. Just the name is fine. So, you can do this: \documentclass{article} \usepackage{amsthm,environ} \renewcommand\newtheorem[2]{% \NewEnviron{#1}[1]{% ##1 : \BODY }% } \begin{document} \newtheorem{acorns}{oaks} \begin{acorns}{trees} leaves and things \end{acorns} \end{document} ...

3

As you are doing inside an environment you need to define \counterIDX "globally" by using \gdef: \documentclass{memoir} \usepackage{totcount} \newenvironment{passagequestions}{% This does not work \gdef\counterIDX{passagecounterX}% \newtotcounter{c\counterIDX}% \total{c\counterIDX}% }{% } \begin{document} ...

2

In principle, this is the way the environ package works: The advantage to using environments is that their contents are not treated as a macro argument, so there are fewer restrictions on what can exist inside, and the processing can be more efficient for long pieces of document text. The disadvantage of environments is that sometimes you really ...

2

It wasn't clear whether you wanted to capture the complete environment body, or only the first item of the environment body. So I show both approaches. To capture the complete body, I use an lrbox and then \unhbox it when needed. For the partial capture, I supply it as an argument and then \gdef it inside the first part of the environment. That way, I ...

2

The usual way for this is to use lrbox; the only quirk is to carry the third argument to the “end part”, which is easy with \colorlet. The problem is that you can't open \colorbox{<color>}{ in the “begin part” and close it in the “end part”. So, with lrbox we store the tabular in a storage bin and use it later as argument to \colorbox. ...

2

\documentclass[12pt]{article} \usepackage[dutch]{babel} \usepackage{blindtext} %Paragraphs get numbered continuously \usepackage{chngcntr} \counterwithout{paragraph}{subsubsection} \setcounter{secnumdepth}{5} \setcounter{tocdepth}{5} \usepackage{titlesec} \usepackage{tocloft} %How stuff is displayed EVERYWHERE ...

2


2

This uses the titlesec package to build on David's suggestion and converts the use of \newenvironment to \newcommand since you want a command rather than an environment judging by the syntax you wish to use. \documentclass[12pt]{report} \usepackage{titlesec} \titleformat{\section}[block]{\centering\bfseries\sffamily\large}{\thesection}{0pt}{}{} ...

1

Try this: \documentclass{article} \begin{document} \begin{tabular}{lp{3.5in}} %% change the number to required number \textbf{Objectives:} & \textit{Finding optimal weights} $\omega^*$ to:\par \textbf{Maximize:} $PICP(\omega)$;\par \textbf{Minimize:} $PIN\ AW(\omega)$.\\ \textbf{Constraints:} & $PIN\ AW(\omega)>0;$\par \$\mu\le PICP(\omega)\le ...

1

Often, less is more. Compare a simple implementation and a fancier one. Not much is, if anything, is gained beyond demonstrating a knowledge of specialized packages. \documentclass{article} \usepackage[T1]{fontenc} \usepackage{libertine} \usepackage{tcolorbox} \tcbuselibrary{breakable, skins} \tcbset{breakable, enhanced jigsaw}% + other stylings... ...

1

Here's an implementation with xparse and environ. The environment's contents is split into lines at \\. Then each line is split at commas and each item is fed as argument to \name. The lines are rebuilt with comma-space between items, and printed in sequence. Final punctuation must be added as an optional argument to the environment. ...

1

You can for instance measure the environment body and perform different things depending on this measurments: \documentclass{article} \usepackage{newenviron,lipsum} \newdimen\hkBstheight \newenviron{hkBstEnv}{% \setbox0=\vbox{\hkBstEnvbody} \hkBstheight=\ht0 \advance\hkBstheight by \dp0 \ifdim\hkBstheight<200pt {\itshape\hkBstEnvbody} \else ...

1

The example environment uses a exampleT environment defined as a theorem-like structure with style blacknumex which adds the little square at the beginning. You can define a similar style blacknumexocresq with the square in ocre color and an exampleM structure using this style. The redefine example to use exampleM instead of exampleT (or define another ...

1

If you are able to settle for verbatim code that is not syntax highlighted, and which does not require page breaking, you could place it in a verbatimbox prior to entering your newly defined solution environment. Of course, by that point, it is in a box, and not available as text. \documentclass[10pt]{book} \usepackage{environ} %\usepackage{listings} ...

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