Latex newcommand optional argument empty

Latex newcommand optional argument empty

Author: SiteSeller Date: 26.05.2017

You can detect whether one is given or not:.

check if a parameter is empty

You'll see that this works by using a lower case 'o', whereas the upper case 'O' then requires a default value which I've made empty by including an empty group. This is probably how you should do it—that will look better with the rest of your LaTeX code. Creating a new environment with optional parameters is done similarly with. If you really want a command in the other form, see the end of my answer. The TeX FAQ has an answer about writing commands with more than one optional argument.

There are two options to how to do it. The underlying idea is to define a command which takes an optional argument, and then runs another command which itself takes an optional argument, etc. First, you define a command which takes a required argument, stores it in a macro, and then forward it onto another command.

XeTeX and LaTeX: Newcommand with an optional argument

This second command takes an optional argument, and uses the defined command and the optional argument. Putting this all together, we get. By posting your answer, you agree to the privacy policy and terms of service. Stack Overflow Questions Developer Jobs Documentation beta Tags Users. Sign up or log in to customize your list. Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of binary options trading university site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us.

Log In Sign Up. Join the Stack Overflow Community. Stack Overflow is a community of 7.

latex newcommand optional argument empty

Join them; it only takes a minute: I'm experimenting with my own commands and environments and now I'm facing those latex newcommand optional argument empty Crowley 1, 5 15 Using the xparse package part of the LaTeX3 development efforts: You can detect whether one is given or not: Joseph Wright 2, 14 I've never seen this package before—that's really cool!

A particular issue is if the macro is used incorrectly, with the optional arg being ommitted: The error messages will have poor readability with your code: I'm not sure what I think about checking for [ —you're right that it will behave unexpectedly, but it actually has a perfectly well-defined behavior printing Required: The actual advice I would give is "don't use this technique"—while it's technically possible, it's probably a bad idea.

Thank you very much for your time spent on this issue. Consider also the xargs package. The following is an example from its documentation. Sign up or log in StackExchange. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name.

Stack Overflow works best with JavaScript enabled. I'm sorry for late reply, I did't have time to try it.

latex newcommand optional argument empty

MathOverflow Mathematics Cross Validated stats Theoretical Computer Science Physics Chemistry Biology Computer Science Philosophy more 3. Meta Stack Exchange Stack Apps Area 51 Stack Overflow Talent.

inserted by FC2 system