Tag Info

Hot answers tagged

10

You should absorb the two arguments verbatim, which xparse allows to do; then you can “rescan” the two arguments when you want to show the effect. \documentclass{article} \usepackage{fontspec} \usepackage{menukeys} \usepackage{xparse} \ExplSyntaxOn \NewDocumentEnvironment{command}{vv} { \tl_set:Nn \l_macmad_argument_i_tl { #1 } \tl_set:Nn ...


6

You can define a command as \newcommand\set[1]{%% \begingroup \def\suchthat{... some definition...}%% ... other macro content .... \endgroup} And this will make \suchthat available inside the macro. You could have done this with \bgroup and \egroup, but that creates a subformula with consequences on how the spacing is handling if used in ...


6

You shouldn't use listings inside arguments, but if you are asking for troubles, another experimental workaround (explained in the documentation) is add a line feed (^^J) at the end of each line, escape \{}% characters and spaces. Unfortunately, then you can’t escape to LaTeX inside such listings (according to package documentation) so you have little chance ...


6

First of all let's see \endflushleft: % latex.ltx, line 3973: \def\endflushleft{\endtrivlist} Now \endtrivlist: % latex.ltx, line 4425: \def\endtrivlist{% \if@inlabel \leavevmode \global \@inlabelfalse \fi \if@newlist \@noitemerr \global \@newlistfalse \fi \ifhmode\unskip \par \else \@inmatherr{\end{\@currenvir}}% \fi ...


5

Don't do this at home... \documentclass{article} \usepackage{xcolor} \usepackage{blindtext} \makeatletter \newenvironment{OuterEnv}{% \parindent0pt Foo \textcolor{red}{\blindtext}% }{% Bar\vskip2\baselineskip% Just for debugging } \newenvironment{InnerEnv}{% \endgroup \end{OuterEnv} % Fails Closing Outer... \textcolor{blue}{\blindtext}% }{% ...


5

I suggest the usage of \createtable as follows: \createtable 3 {3cm} {Label1} {Label2} {Label3} {Text1-Label1 | Text1-Label2 | Text1-Label3 | Text2-Label1 | Text2-Label2 | Text2-Label3 } {Table title} You can see that you must specify the number of columns (3 in the example) and the width of columns (3cm in the example). You are ...


5

If you input the labels in a unique argument, it's easy to figure out the number of columns. \documentclass{article} \usepackage{xparse} \usepackage[table]{xcolor} \usepackage{tabularx} \usepackage{booktabs} \ExplSyntaxOn \NewDocumentCommand{\createtable}{mm} { \sandeep_ct_create_table:nn { #1 } { #2 } } \int_new:N \l_sandeep_ct_cols_int \seq_new:N ...


5

The vertical spacing is different, but only noticeable in certain instances. To see this, consider all the possible ways in which you can have text around these displays: \documentclass{article} \usepackage{amsmath} \setlength{\parindent}{0pt}% Just for this example \begin{document} Long/long line before/after display: \begin{minipage}[t]{.5\textwidth} ...


5

I think you want something like \documentclass{article} \usepackage{lipsum} \setlength{\parindent}{0pt} \newenvironment{mytable}[1]{% \begin{list}{}{% \setlength{\leftmargin}{2em} \setlength{\topsep}{5pt} %desired vertical separation of table from } %surrounding text ...


5

A. Ellett's suggestions are good, but there are some subtleties connected with this approach. Localizing the definition with \bgroup and \egroup is bad, because the \set macro is clearly used in math mode. Such a construction would make a subformula, with the consequence that spaces are frozen and don't participate with stretching and shrinking on the ...


4

Is not exactly what you asked, but may be is useful for someone. The advantage is that the tcolorbox package can print the LaTeX code and the result of this code in a environment with a lot of options. \documentclass{article} \usepackage[most]{tcolorbox} \usepackage{menukeys} ...


4

listings is essentially a verbatim environment that turns off normal latex processing, in particular \end{hello} does not end the environment. The package has facilities for defining custom environments, see section 4.16 of the listings manual. \documentclass{article} \usepackage{listings} \lstnewenvironment{hello}{\lstset{language=sh}}{} ...


4

This should do as wanted, and also allows multiple arguments. The only problem is that if there are control sequences in the second argument they are appended with a space. \documentclass{article} \usepackage{fontspec} \usepackage{environ} \usepackage{marginnote} \usepackage{menukeys} \NewEnviron{command}[2]{% \par ...


4

As stated in the comments, the only difference is the spacing of the formulas. You should attempt to use equation when possible, and align when you have multi-line formulas. Also: equation throws an error when you have an & inside the environment, so look out for that when converting between the two.


3

I think this command is only available from inside a beamer template. In any case, redefining the frame environment is a bad idea. Instead, try changing the style using beamer template commands (you may need to adjust the spacing): \setbeamercolor{frametitle}{fg=black} \setbeamertemplate{frametitle}{ \vspace{4cm} \begin{tikzpicture}[remember ...


3

Two solutions, with the cellspace package, which defines minimal vertical spacings at the top or the bottom of cells, or with makecell, which defines vertical spacings to add at the top or the bottom of cells: \documentclass{article} \usepackage{lipsum} \setlength{\parindent}{0pt} \usepackage{cellspace} \newenvironment{mytable}[1]{% \begin{list}{}{% ...


3

Doubt this is what the OP wants, but every now and then it's nice to do something from (almost) first principles, and convince myself that all that time I spent years ago reading Stephan von Bechtolsheim's TeX in practice wasn't completely wasted. Note that the use of \scantokens assumes that etex is used. \documentclass[border=10]{standalone} ...


3

You need to perform a string comparison with the expansion of \@currenvir against itemize. \ifthenelse with the \equal operator does this, but you're short a magic \makeatletter...\makeatother wrapper (see What do \makeatletter and \makeatother do?). Consider the post Why is the ifthen package obsolete?, I've used the e-TeX \pdfstrcmp to perform a string ...


3

I'm not sure this is really what you want: the result is just wrong, nobody will understand why the text in the second and third footnote is shifted right. \documentclass{memoir} \setlength{\footmarkwidth}{\leftmargin} \setlength{\footmarksep}{0em} \footmarkstyle{#1\hfill} \newenvironment{fnquote} {\par \setbox0=\lastbox \setbox2=\hbox{\unhcopy0}% ...


2

If you want to avoid the list environment, you could just make one environment for your structure build around a minipage. The problem with this is that it will not break across pages. But since you mentioned subfig I'm assuming that this environment isn't something that is intended to span multiple pages. \documentclass{article} ...


2

My solution uses the temporary external file. The data are scanned in verbatim mode and saved to the file. Then the file is read with normal catcode settings, so the normal output is printed. Then the data from verbatim scan is used for verbatim output. \documentclass{article} \newwrite\verbfile \def\setverb{\def\do##1{\catcode`##1=12}\dospecials} ...


2

Using a hack of the example package. It could be a good idea make directly your own package based in example.sty instead of muddle the preamble on this way. \documentclass[a4paper]{article} \usepackage[margin=3cm]{geometry,xcolor} \usepackage{example,booktabs} \parindent0pt\parskip0em \columnsep .1\textwidth \makeatletter \chardef\escape=0 ...


2

It seems like this is also a situation where \scantokens could come in nicely: \documentclass[a4paper]{scrreprt} \newcommand{\cmd}{\begingroup \catcode`_=12 \cmdint} \newcommand{\cmdint}[1]{% \texttt{\scantokens{#1\noexpand}}% \endgroup } \newenvironment{wrap}{}{} \usepackage{environ} \NewEnviron{wrap2}{\BODY} \begin{document} \cmd{some_test} ...


2

This is due to an additional \begingroup / \endgroup pair which is introduced by \newenvironment combined with deep magic which communicates the set of graphics layers from the axis to the tikzpicture. There are basically three ways to solve it: 1] Activate layered graphics manually before your axis: \documentclass[class=minimal,border=0pt]{standalone} ...


2

When you say, \newtheorem{theorem}{Theorem}[section] the theorem is numbered within section. Since you want it to be numbered within subsection make it \newtheorem{theorem}{Theorem}[subsection] as already commented by egreg. Further, when you write \newtheorem{corollary}[theorem]{Corollary} The corollary and theorem share the same counter i.e., ...


2

For such jobs, tcolorbox is more suitable. The advantage here is the box is breakable across pages. \documentclass{article} \usepackage{showframe,lipsum} %% just for demo \usepackage[most]{tcolorbox} \definecolor{block-gray}{gray}{0.85} \newtcolorbox{myquote}{colback=block-gray,grow to right by=-10mm,grow to left by=-10mm, ...


2

You can do that easily with the ntheorem package (instead of amsthm) and etoolbox. I also loaded the enumitem package to improve the layout of itemize environments in such context. Here is a possible code: \documentclass[11pt,a4paper,openany]{report} \usepackage[utf8]{inputenc} \usepackage{amssymb, mathrsfs} \usepackage[dutch]{babel} \usepackage{lmodern} ...


2

You have to expand \BODY before \begin{mytaskenum} starts its job: \documentclass[a4paper]{book} \usepackage{environ} \usepackage[more]{tasks} \NewTasks[style=enumerate,counter-format=tsk[1]),label-width=2ex]{mytaskenum}[\item](3) \NewEnviron{mytaskenv}[1][Exercises]{% % Misc. stuff to preceed the tasks env here \def\tempbegin{\begin{mytaskenum}}% ...


2

The reason why arguments cannot be used in the “close” part of the environment's definition is simple: \newenvironment{foo}[1] {<start-code>} {<finish-code>} actually does something roughly equivalent to \newcommand{\foo}[1]{<common start-code><start-code>} \def\endfoo{<finish-code><common finish-code>} where the ...


2

The \label command saves the index of counter that was last used in the \refstepcounter command. As the \caption command always calls \refstepcounter{algorithm}, the \label is always associated with the algorithm counter and hence cleveref prints Algorithm instead of Kernel. The easiest solution I can think of is just calling \label before calling ...



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