Questions tagged [key-value]
{key-value} is about packages and macros using the key=value syntax for named parameters instead of numbered parameters.
281 questions
3
votes
4
answers
266
views
Define a command with keys as arguments AND allow the default values depend on each other
Is there a way to define a command\foo taking a key list as its argument AND have the following feature:
The default values of some of the keys (saying, b and c) rely on some other keys (saying, a).
...
4
votes
2
answers
130
views
How to define a .meta:n key preserving hashes?
I have a command that sets some keys, does stuff with the keys, and defines a new "meta" style with those keys to be called later with inherit-style=<style name>. This works fine using ...
4
votes
1
answer
96
views
Formatting keyvalues in enumext package
Consider the following MWE:
\documentclass[letterpaper]{article}
\usepackage{xcolor}
\usepackage{enumext}
\setenumext[enumext, 1]{%
label={\arabic*},
font={\bfseries}
}
\setenumext[...
1
vote
2
answers
88
views
Is this code idiomatic?
I am writing a math paper consisting of several Definitions, Lemmas, Theorems, Corollaries, etc. Every such part can have a title and/or a reference. In the text, I would like to have both the title ...
4
votes
4
answers
450
views
Is there any way to replace consecutive 'def'
\documentclass{article}
\usepackage{siunitx}
\begin{document}
\def\aa{11}
\def\bb{22}
\def\cc{33}
\def\dd{44}
% Is there any way to replace above consecutive 'def' by equal sign , such as
aa=...
2
votes
1
answer
129
views
Add `.meta` key to existing keys (l3keys)
I have two list environments called myenv and myenv* where only the first one has four levels, the keys for the first one are stored in { mymodule / level-1 }, ...,{ mymodule /level-4 } and for the ...
2
votes
2
answers
63
views
PGF keys are setting individually but not as a key list
Using the TeX Works AppImage with a local installation of TeX Live (texlive-full, 2021.20220204-1), I'm having trouble getting "pgfkeys" to work with a key list. Setting each key ...
0
votes
1
answer
58
views
passing a group of package(class) options in 1 key using l3keys2e in latex class
problem
I want to writing a docuementclass, called it foo.cls in the following context. Assume there is a document class called bar.cls, which can accept the following key-value(options):
\...
1
vote
1
answer
109
views
Adapt and extend a command for key-val parse (l3keys)
I have a parser for the environment keys and command of a package and it works very well. For MWE purposes I have two environments myenv and myenv*, both represent list environments, but only the ...
0
votes
0
answers
49
views
Making keys global or reference them outside scope
I made this code to be used as an answer here: Efficient "macro" for adding second (x-)axis to pgfplots and more generally.
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
...
5
votes
2
answers
176
views
Why can I not correctly reset a key in l3keys?
To help me learn l3keys I created two small demos.
The first uses l3keys for a command and seems to work correctly as far as I can tell.
% !TEX program = lualatexmk
% !TEX encoding = UTF-8 Unicode
\...
0
votes
3
answers
96
views
Unexpected behavior of \g@addto@macro in class definition
I am implementing a new class for a journal.
Withi this class, I defined the command to insert the authors of an article.
I anticipate that everything works perfectly in the basic form, that is, if ...
10
votes
1
answer
417
views
Moving from pgfkeys to latex3 key-val system to handle package options
I have been advised in this question to move from pgfopts to latex3 to handle package options. I would like to do that but I must admit that I am a little lost. Examples with the patterns I'm using ...
1
vote
2
answers
237
views
What is the most general form of key-value pairs for options?
Strange question I know.
I know that it is possible to have options, to be more precise option keys,
consisting of letters, but there seem to be possible more.
some option keys seem to have a value ...
1
vote
1
answer
117
views
Braces in l3keys
In many cases, the braces surrounding values to keys in l3keys are omitted when defining keys, even when the keys themselves have n-,c-, or e-type arguments, which normally require braced arguments. ...
0
votes
1
answer
69
views
Can't pass choices option to package
I am trying to make a custom package to contain all my personal macros and a custom class for my personal style. I wanted to pass a keyword argument notation which can take a value of math or physics ...
8
votes
2
answers
393
views
Weird error in custom package instead of the error I tried to throw?
I am making a custom package for all my personal commands, and I am trying to pass some keyword arguments to the package as described in section 4.4 of clsguide. My use case is that I take math and ...
4
votes
3
answers
225
views
tikzset style - use a command to generate multiple key-vals
When creating a style with args using \tikzset, I have no problem creating "aliases" with args, as long as those args appear in the value part of a key=value, like xshift=#1. What I want to ...
3
votes
2
answers
146
views
Expand key-values with \def of \newcommand?
I have multiple repeated
\begin{enumerate}[label=A\alph*), ref=A\alph*]
and I want to reduce code duplication. I would also like to avoid creating new environments if possible. I just want a simple ...
1
vote
1
answer
116
views
Unable to find error in my latex code
Hello LaTeX Community,
I was working on a template and almost finished it, but there was a glitch in my code and I was unable to find it. While rendering the code, the \textbf{Question \questionnumber:...
10
votes
3
answers
585
views
Avoid spurious warnings in a parasitic class with key-value options (LaTeX3 \DeclareKeys)
This is a modified version of "Unused global options(s)" when using arguments in options of class. The question is how to create a parasitic class (i.e. one which loads another) which ...
4
votes
1
answer
99
views
How to use similar package and command keys, should they be separate or the same variable?
I am writing a expl3 package for typesetting amino acid residues and I am still getting to grips with LaTeX3 and the interfaces documentation. I have looked at the nicematrix annotated code for ...
0
votes
1
answer
55
views
LaTeX3 package option .initial:N is not being respected and used in a command
I asked a question earlier that was helpfully answered by Skillmon but have ran into an issue when relying on the .initial:N value of a package option e.g.
\usepackage[superscript-fontsize=large]{...
9
votes
2
answers
210
views
l3keys equivalent of pgfkeys' .code 2 args
What is the recommended way to emulate pgfkeys' /.code 2 args (or more generally /.code n args) handler with l3keys? For example, with pgfkeys one can do
\documentclass{article}
\usepackage{pgfkeys}
...
1
vote
1
answer
98
views
Strict version of \keys_set_groups:nnn
Here's a little code where the key-value allowed by the macro is an unwanted feature : for example, single[both = OK, only = KO] doesn't give any error as I'd hoped. But on the other hand, I would ...
2
votes
2
answers
54
views
Setting beamer label from xparse option
I want to write a custom environment that handles some layouts that default beamer slides aren't designed to do.
I use xparse's \NewDocumentEnvironment to achieve this, but have problems passing down ...
4
votes
1
answer
145
views
key property .notif is unknown
Following the example in The LaTeX Companion, 3rd edition, Part II, page 700, I'm trying the following .sty file and .tex file that loads it, but I get error:
./myfont.sty:8: LaTeX Error: The key ...
5
votes
4
answers
292
views
Passing macro parameters with \DeclareKeys/\SetKeys
Just as an exercise I'm trying to make a keyval interface to amsthm's \newtheoremstyle in the manner of thmtools, but using the kernel's \DeclareKeys instead of keyval and kvsetkeys. Every argument of ...
0
votes
1
answer
77
views
Multilange support - need some help in xkeyval
I'm trying to do some improvements in the multiaudience package. In particular, I would like to have one latex document containing multiple languages.
For simplification reasons the texts of the ...
1
vote
2
answers
485
views
Good practice with \DeclareKeys
I'm trying to make a "one-off" theorem environment for theorems with custom names that shouldn't be numbered at all. The goal is to copy the behavior of thmtools
\declaretheorem[thmbox=M]{...
1
vote
0
answers
124
views
Use of xparse macro and expl3 key-value pairs [closed]
I'm trying to set up a family of key-pairs to be used in a \NewDocumentCommand. The goal is to have a function with two key-pairs. I want to be able to get the values of the two keys within the macro, ...
1
vote
1
answer
383
views
Using \DeclareKeys as a document author/designer
Say I want to use a package using l3keys for it options, e.g. I want to print numbers using siunitx's \num. I load it with my desired default options (e.g. just \usepackage{siunitx}) but have a ...
1
vote
1
answer
56
views
How to find out available key-value pair for CircuiTikZ
I'm using CircuiTikZ and I came across this issue frequently: every time I want to tweak some options using tikzset, there is no documentation for the available key-value pairs.
For example, if I want ...
1
vote
1
answer
89
views
\SetKeys (ltkeys): property '.default' is unknown?
Reading 'source2e.dtx' suggests that the 'l3keys' property '.default' should be available. The following MWE doesn't work as I expected though:
\documentclass[a4paper]{article}
\usepackage{color}
\...
0
votes
1
answer
124
views
Handling "family=" and "given=" within the "author" field
My zotero+BetterBibTeX has exported some citations like this
@article{abduMagneticDeclinationControl1981,
title = {Magnetic Declination Control of the Equatorial {{F}} Region Dynamo Electric Field ...
0
votes
1
answer
72
views
Can't make a list of keys work
I am trying to make my own chapter-heading formatting command, using a key=value approach:
\coolchap[
chapstyle=<chapter-word formatting>,
titlestyle=<chapter-title formatting>,
befchap=&...
2
votes
2
answers
123
views
Define custom keys for graphicx
I would like to define some shorthand keys for includegraphics[]{} like so:
fullwidth -> width=\textwidth, halfwidth -> width=0.5\textwidth etc.
What is the best approach for this?
0
votes
1
answer
70
views
Loop in a specific list to define class options
I have a class beamer-rl to create beamer presentation for RTL languages (like persian) and I need a way to include RTL language as a class option like this \documentclass[persian]{beamer-rl}
So class ...
2
votes
0
answers
62
views
Options passed to babel with article class and not with beamer
In this example using article class options arabic-ma and provide=* are passed to babel, but when changing to beamer class options are not passed to babel. Is there an explanation?
\documentclass[...
4
votes
2
answers
358
views
Is there a way to reset all l3keys keys to their initial value?
This is a general and documented feature of latex3, but I shall still provide an MWE in order to illustrate the problem, see below.
Suppose I have a function which uses the l3keys key-value interface, ...
1
vote
1
answer
70
views
Pgfkeys associated with macros lead to unexpected results
Consider the following class:
% CLASS
% Preamble
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesClass{myclass}[2022/10/11]
\LoadClass[varwidth]{standalone}
\makeatletter
% Pgfoptions
\RequirePackage{...
0
votes
1
answer
90
views
keyval being picky about empty options
I am trying to automate the generation of beamer handouts, with the help of \pgfpagesuselayout. I want them with 2 slides on 1 page, my colleagues with 4 in landscape orientation. So we generate both ...
0
votes
1
answer
67
views
Split nested and simple comma lists the same way
\documentclass{article}
\usepackage{kvsetkeys,kvdefinekeys}
\makeatletter
\def\Process@Split#1{%
\if@tempswa
\edef\ST@LastName{\comma@entry}%
\typeout{* LastName:\ST@LastName}%
\@...
0
votes
2
answers
135
views
Taking in optional boolean flags in a macro without expl3
I want to create a macro \verticalStep which will produce a vertical skip of fixed length, and take two optional arguments, negative and small.
So for you could use
\verticalStep for a standard ...
3
votes
0
answers
157
views
Unknown options fail to pass with new expl3 method [closed]
Recently I switched my packages to use the new \ProcessKeyOptions method for processing package options. However, I just found out that with
\keys_define:nn { projlib-theorem }
{
...
, ...
1
vote
1
answer
146
views
Is it safe to use \globaldefs for setting global pgf key-value pairs?
With the help of this post (Is there a way to set a *global* key value using `pgfkeys`?), I found a simpler way to implement a solution to my own question (How can I create commands using multiple ...
0
votes
3
answers
169
views
How can I create commands using multiple arguments with pgfkeys in custom environments with tabulars? [duplicate]
I am trying to create my own template package.
In this package, there are several custom environments defined. One of those environments starts and ends a table, i.e:
\newenvironment{customenvtab}{\...
7
votes
3
answers
609
views
How to define new key properties in l3keys
Related Meta Question
From interface3.pdf, we can see l3keys has provided several key properties such as .code:n, .tl_set:N, .usage:n. But I don't know how to define a new key property.
At this time, ...
6
votes
1
answer
601
views
As of 2022, how should one build class/package options without l3keys2e? [duplicate]
In a comment of this question,David Carlisle wrote:
[l3keys2e] should be considerd legacy now, the new built in option code is based on the same core expl3 code but extended and improved so hopefully ...
5
votes
4
answers
281
views
What is the best way to expand macros inside keyval input in expl3
I think LaTeX packages rarely use macros as key names. And some users expect macros inside the keyval input will be expanded recursively first. But l3keys in expl3 doesn't provide this functionality ...