17
votes
2answers
217 views

Can I turn a collection of optional parameters into a macro?

I currently have several environments from mdframed that have a large number of options that are shared between them. The situation looks like \newmdtheoremenv[options0,options1]{env1}{Environment 1} ...
3
votes
1answer
46 views

How to define a function with optional key-value arguments [duplicate]

I have setup a function called quickfigure which has the purpose of inserting a centered image with a one-line command: \newcommand{\quickfigure}[2] { \begin{figure}[H] \centering ...
5
votes
1answer
106 views

Key value options in combination with TikZ

I'm trying to create some TikZ commands that use key value options. Using the following link: How to create a command with key values? I was able to declare some commands, but now I'm stuck. As a MWE ...
5
votes
1answer
61 views

How to pass comma in value of a (xkeyval) comma separated list of values at \documentclass level?

At \usepackage level, xkeyval allows us to insert commas in value of a comma separated list of values: it is enough to enclose in braces the values containing commas. For instance, the following MCE ...
5
votes
1answer
68 views

How to choose between arguments and keys when defining a macro

I would like to know if there are guidelines for package writers regarding the interface preferred for passing arguments to macros. Suppose I am writing a package for typesetting a titlepage. There ...
4
votes
2answers
78 views

Keyword command parameters with table (tabular)

I am trying to make a command with named (key-value) parameters to produce a table row. The reason is that table has more than 9 columns (command parameters) that will have position changed, be ...
8
votes
2answers
216 views

xparse and key value arguments

I'm trying to learn how to do macros. I want to use xparse as it seems the most powerful tool. I also want named arguments, as numbered arguments make me, as a programmer, uncomfortable. I had some ...
9
votes
1answer
108 views

Expandable, very specific keyval processing

I am having a hard time trying to come up with an fully expandable keyval parsing macro which deals only with specific keys/values. I wouldn't even attempt this in full generality, that's way beyond ...
8
votes
2answers
372 views

Pass named arguments to macro

I notice that includegraphics takes what seems to be named arguments: \includegraphics[width=50,height=25,trim=1 2 3 4,clip]{an_img.png} I'd like to wrap a number of my includegraphics calls in a ...
6
votes
1answer
127 views

Forcing macro expansion with keyval

While trying to provide an answer to this question, I've run into a stumbling block that I can't seem to get over. The listings package (like many others) uses keyval to handle configuration. What ...
2
votes
1answer
287 views

newcommand key value

This is a completely noob question for LaTeX package writers. Could somebody share a piece of code or a MWE for the following situation. I would like to define a newcommand which will depend on the ...
7
votes
3answers
384 views

How to define a key=value that has an equivalent boolean value key

Assume you're defining a key=value align for some environment realign that you'll use in the following way: \usepackage{xkeyval}% http://ctan.org/pkg/xkeyval \newenvironment{realign}[1][] ...
6
votes
1answer
581 views

Using a macro as value of addtotoc in \includepdf

I would like to include pages from an external PDF file into my document, using the pdfpages package. The following works for me: \documentclass{article} \usepackage{pdfpages} \begin{document} ...
6
votes
2answers
142 views

Writing a macro with parameters

I'm trying to write a macro which should be able to do several different yet somewhat similar things. I thought that instead of writing different macros for every thing, I should be able to write just ...
39
votes
4answers
2k views

How to create a command with key values?

I am trying to create a command that the user can enter keys for values. How can I create one, for example: \myparbox[width=50,height=10,color=blue, align=left -10px]{}