Tag Info

Hot answers tagged

20

LaTeX macros for defining custom commands and environments include: \newcommand \newcommand* \renewcommand \renewcommand* \providecommand \providecommand* \newenvironment \newenvironment* \renewenvironment \renewenvironment* It is best to start with these since you should prefer them to TeX macros such as \def. However, sometimes only the TeX macros will ...


11

You need to assemble the control sequence name before defining with \newcommand, and before using it. This can be achieved using \expandafter twice. \newcommand{\deflen}[2]{% \expandafter\newlength\csname #1\endcsname \expandafter\setlength\csname #1\endcsname{#2}% } \deflen{mylength}{12pt} \showthe\mylength


6

The environment form of \parbox is minipage: \newenvironment{CV} {\begin{minipage}{0.2\textwidth}\raggedright} {\end{minipage}} Note that you don't want a flushleft environment inside the minipage, because it adds vertical space fore and aft; with \raggedright this doesn't happen. Now you can call \begin{CV} Text \end{CV}


5

The error message of LaTeX is wrong, it should read: ! LaTeX Error: File `../common/{preambleCommon}.tex' not found. The the error is clear: the curly braces. They are not removed as argument braces, because \commonDir does not take an argument in \input{\commonDir{preambleCommon}}. Corrected: \newcommand*{\commonDir}{../common/}% \input{\commonDir ...


5

Ian Thompson's code is good, but you could add the check whether you can define a new length in the first place; calling, say, \deflen{textwidth}{6pt} would issue an error message at \newlength, but it would set \textwidth nonetheless. Since you are in a style file you don't need \makeatletter for @ commands, so you can do \newcommand{\deflen}[2]{% ...


4

One option using titlesec; the command \standardchapter produces a "normal" heading; \combinedchapter produces a heading in each the numbering has the form <number>.-- <number>+#1, where #1 is the integer in the mandatory argument: \documentclass{book} \usepackage{titlesec} \newcommand\standardchapter{% \titleformat{\chapter}[block] ...


3

Here is something that you could use as a start: \documentclass{report} \usepackage[margin=1in]{geometry}% Just for this example \makeatletter \newcommand{\printcases}{\@starttoc{cse}} \newcommand{\l@case}{\@dottedtocline{1}{0em}{1.5em}} \makeatother \newcommand{\case}[6]{% \addcontentsline{cse}{case}{#1: #2} \begin{description} \item[Case]: #1 ...


2

The tcolorbox package provides a macro called \newtcolorbox to define custom environments; see section 2 in the manual (top of p12, in the current version). Under the assumption that you just want to change the colour, not the tints/shades, you could define a new environment that accepts three arguments (the first of which is optional): additional ...


1

The following example defines \chapterA with a range as chapter number. Also chapters inside the appendix are supported. Because of the longer numbers, the table of contents is adjusted accordingly. \documentclass{scrreprt} \let\savedthechapter\thechapter \let\orgchapter\chapter \renewcommand*{\chapter}{% \let\thechapter\savedthechapter \orgchapter } ...



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