Linked Questions

53
votes
1answer
48k views

Optional argument for newcommand? [duplicate]

Possible Duplicate: Different command definitions with and without optional argument I would like to define a macro which takes an optional argument, and behaves in different ways depending on if ...
10
votes
4answers
537 views

New command with two definitions [duplicate]

I want to define a new command that serves two slightly different purposes. Can I define a new command called \set such that it's definition is chosen according to the number of argument(s) is(are) ...
657
votes
1answer
135k views

What do \makeatletter and \makeatother do?

Many LaTeX “hacks” begin with \makeatletter and end with \makeatother. What do these commands do?
16
votes
3answers
1k views

Conditionally Remove Brackets

I'm trying to create a command with an optional argument using \newcommand{\Af}[1]{{\mathbf{A}_{(#1)}} where the argument is a number. However, I'd like that if no argument is given the bracket ...
20
votes
2answers
4k views

New command with optional argument being first argument [duplicate]

I know I can create a new command with an optional parameter with \newcommand{\mycommand}[2][Hello]{\textbf{#1} #2} I would like to have the command such that there is an optional parameter which ...
22
votes
4answers
9k views

Cornell Notes - A lyx or latex solution needed

I teach academic writing to computing students and one of the tasks they have to carry out is to compile a set of research notes which can then be developed into an essay. I find that the Cornell ...
10
votes
5answers
2k views

Parsing optional macro arguments

I am trying to define a macro with flexible arguments: 3 mandatory and 2 optional ones - like this: \macro{<enter code here>}[arg2] arg3 = arg4 | arg5; So args 2 and 5 are optional, as is the |...
10
votes
4answers
4k views

\newcommand with options

My question is about declaring a "newcommand" with an option. I have defined \newcommand{\bforall}[2]{\forall #1\, (#2)} so that $\bforall{x}{x \in A}$ writes $\forall x (x \in A)$. I would like ...
13
votes
5answers
579 views

Two independent optional arguments for new commands

I'm trying to adapt the solution provided in Different command definitions with and without optional argument to change the behavior of my new command. I'd like to use basic command to avoid some non ...
8
votes
4answers
916 views

How can I get curly arrow underneath a state in a state transition diagram

I have a simple state transition diagram that I'd like to render in latex ideally using regular mathmode markup. The arrows show the probability of going between states. \underbrace{\boxed{A}}_{1/4} \...
9
votes
1answer
6k views

How do I use the etoolbox package to check if an argument to a macro was defined?

I saw this answer, which uses the etoolbox package to create a macro with an optional argument. Unfortunately, I can't get it to work. Here is a minimal working example: \documentclass[12pt]{article} ...
12
votes
2answers
2k views

How do I put card backs on my cards?

I have a a document that is making me sheets of cards. A stripped down, almost minimal example looks something like \documentclass{article} \usepackage[utf8]{inputenc} %Needed for input \usepackage{...
5
votes
2answers
756 views

Different macro behavior when supplied an argument

I want to define a macro, call it \func, so that \func will output\phi, and \func[i] will output \phi(i). what is the easiest way to achieve this? I know there are other questions that address this ...
3
votes
3answers
294 views

Check macro argument has correct format

I have a macro which will read in arguments in date format e.g. {2012-11-08} \usepackage{datetime} \def\customdate#1#2#3#4-#5-#6\relax{% \shortmonthname[#5] '#3#4% } However, in some instances I ...
4
votes
3answers
686 views

TikZ: How to draw lines between a set of points and their scope-images and fill the enclosed area?

Following this answer, I need to: draw a horizontal line between point a and its scope-image, and draw another horizontal line between point b and its scope-image fill the trapezoid whose sides are ...

15 30 50 per page