0

Can someone tell me how to set the parameters of a declared new command similar to how it is set in the TikZ package? More specifically, I would like to declare a function \condVert{} that sets a vertical line to the right of the selected expression (environment \left. + \right|) indicating a condition (or the limits of a variable change). Also, as an additional parameter, I would like to set the ability to set brackets / frames around the expression.

Examples:

Command Result Comment
\condVert[lim={x=0 | a}]{f(x)} enter image description here
\condVert[limits={x=0 | a}]{f(x)} enter image description here lim and limits in the settings should give the same result.
\condVert[lim={x=a}, angle bracs]{\dfrac{x^2}{2} + x} enter image description here I would also like to be able to use syntax like [...brackets=angle].
\condVert[lim={x=a}, rangle bracs]{\dfrac{x^2}{2} + x} enter image description here
\condVert[lim={x=a}, {dash box}]{\dfrac{x^2}{2} + x} enter image description here
\condVert[lim={x=a}, {dash circle box}]{\dfrac{x^2}{2} + x} enter image description here

Highlighting the background color would probably be too expressive, but perhaps it would be good to add to the functionality. :)

Ingmar
  • 6,690
  • 5
  • 26
  • 47
Sssur
  • 97

1 Answers1

1

Here is a solution via my own, slightly non-standard package, SemanTeX. I took the liberty to change the order and meaning of some arguments and keys in a way that made the implementation easier:

\documentclass{article}

\usepackage{semantex}

\NewVariableClass\condVert[ define keys[2]={ {limits}{ Other spar={.}{|}{auto}, lower={#1}, upper={#2}, }, }, define keys[1]={ {lim}{ limits={#1}{} }, }, define keys={ {angle bracs}{ Other spar={(}{)}{auto}, }, {rangle bracs}{ Other spar={[}{]}{auto}, }, {dash box}{ command=\dashboxcommand, }, {dash circle box}{ command=\dashcircleboxcommand, }, }, ]

\newcommand\dashboxcommand[1]{% #1% change to suit your needs }

\newcommand\dashcircleboxcommand[1]{% #1% change to suit your needs }

\begin{document}

\begin{gather} \condVert{f(x)}[lim={x=0}] \ \condVert{f(x)}[limits={x=0}{a}] \ \condVert{\dfrac{x^2}{2} + x}[angle bracs,lim={x=a}] \ \condVert{\dfrac{x^2}{2} + x}[rangle bracs,lim={x=a}] \ \condVert{\dfrac{x^2}{2} + x}[dash box, lim={x=a}] \ \condVert{\dfrac{x^2}{2} + x}[dash circle box, lim={x=a}] \end{gather}

\end{document}

enter image description here

Gaussler
  • 12,801
  • Thank you very much, I believe this will be a good help for my needs. :) Of course, I'd like to know the solution by native TeX methods, without involving third-party packages. – Sssur Jun 17 '22 at 17:33
  • @Sssur I’m not really sure what you even mean by “native TeX methods” vs. “third-party packages”. LaTeX itself is a third-party package to TeX, and TikZ is a third-party package to both LaTeX and plain TeX. Unless you are a masochist, then trust me, you do not want to create your own keyval parser from scratch using plain TeX commands. You will have to rely on some other package like l3keys, keyval, pgfkeys, or expkv. The first one is now built into LaTeX and is therefore the closest thing you get to a “first-party” keyval implementation. SemanTeX is indirectly based on l3keys. – Gaussler Jun 19 '22 at 07:04