LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Command that takes optional arguments (https://www.linuxquestions.org/questions/linux-newbie-8/command-that-takes-optional-arguments-4175717252/)

Faki 09-28-2022 03:29 PM

Command that takes optional arguments
 
I want to make a latex command that takes optional arguments


Code:

\newcommand{\vamt}{1.5cm}
\newcommand{\vspc}[1][\vamt]{\vspace{#1}}

I define a variable "\vamt" that stores the amount of vertical skip. The command "\vspc" takes one optional arguments which can default to "\vamt" when no argument is passed to the command.

Taking the following as example, I get a "1.5cm" vertical space between "Paragraph 1" and "Paragraph 2". But instead of getting "2cm" between "Paragraph 2" and "Paragraph 3", I am simply getting "2cm" being printed as text, with the paragraph spacing still at "1.5cm".

Code:

To prove it by contradiction try and assume that the statement is false,
proceed from there and at some point you will arrive to a contradiction.

\vspc
To prove it by contradiction try and assume that the statement is false,
proceed from there and at some point you will arrive to a contradiction.

\vspc{2cm}
To prove it by contradiction try and assume that the statement is false,
proceed from there and at some point you will arrive to a contradiction.


rtmistler 09-28-2022 04:24 PM

Quote:

Originally Posted by Faki (Post 6383167)
I want to introduce a blank line in my document. But have seen that "" and "\newline" do not always make a blank line. Only "\hfill \break" seems to work consistently.

Please provide an example demonstrating what this appears like working vs not.
Quote:

Originally Posted by Faki (Post 6383167)
Then one finds "\smallskip", "\medskip", and "\bigskip". Which do a better job.

Please provide some context, better descriptions, or examples which cite what constitutes a better job.
Quote:

Originally Posted by Faki (Post 6383167)
I do use indents for paragraphs without blank lines between them. But at times I would need a blank line between a paragraph and the next.

Should I make a new paragraph command or simply let the user insert "\bigskip"?

Can you please illustrate what these two options appear like?
Quote:

Originally Posted by Faki (Post 6383167)
Have also played with "\setlength{\parindent}{0pt}". Would this be a bad idea?

Please illustrate what effects you have seen using "\setlength{\parindent}{0pt}" and indicate why this was not a solution for you.

Latex is a very detailed and specialized documentation preparation system.

There are a number of ways to attain certain results.

Please bear in mind that it may be very helpful to give a visual description of the desired outcome, as opposed to asking about various terms. Anyone trying to help would want to know how you wish the results to appear as and also where you did try something, how the result did not match your desired outcome.

Many times, input accompanied by desired output, as well as interim not fully resolved output will help people understand what each goal is.

marijan 09-29-2022 01:39 PM

Well, in other thread (now closed) should
command be called with \vspc[2] instead of \vspc{2}.

Faki 09-29-2022 01:56 PM

People have been continuing to close my post saying they were duplicates, but which were not. This place is quite depressing when people are allowed to mess with other people's posts.

marijan 09-30-2022 01:22 PM

I wouldn't know about it. I am mostly lurking here once in a week. I hope I helped with the latex.

computersavvy 09-30-2022 04:26 PM

Quote:

Originally Posted by Faki (Post 6383455)
People have been continuing to close my post saying they were duplicates, but which were not. This place is quite depressing when people are allowed to mess with other people's posts.

Moderators make those decisions, not other users.
If you have an issue with a particular post that was closed you should contact a moderator with your concerns.

As I understand it such decisions are not arbitrary but actually based on the content of the post that gets closed and all related posts.

marijan 09-30-2022 09:41 PM

Quote:

Originally Posted by computersavvy (Post 6383692)
Moderators make those decisions, not other users.
If you have an issue with a particular post that was closed you should contact a moderator with your concerns.

As I understand it such decisions are not arbitrary but actually based on the content of the post that gets closed and all related posts.

It's a true. But someone has to report the post, before moderators decide to close it. Just for fun.

rtmistler 10-01-2022 09:42 AM

Quote:

Originally Posted by Faki (Post 6383455)
People have been continuing to close my post saying they were duplicates, but which were not. This place is quite depressing when people are allowed to mess with other people's posts.

Many of your questions are similar and do not provide sufficient details for people to provide answers. The questions are unclear, do not provide enough information, and the evaluations have been that there is duplication.

If you feel a thread has been closed incorrectly, please use the Report button to request reopening of a thread, however it is also best to provide supporting information and revised content for the post of the thread in question so that the moderators may amend your thread question to make it more clear. Without proper context and revised content, the moderators may have little choice except to leave certain threads closed.

Members please stay on topic in this thread moving forwards.

Some additional information has been requested here and there have not been any additional details provided. Please see post #2 for the additional details. Being more clear with your question by providing example input/output and explaining the details about what exactly you have tried, what you expected to occur, and what instead occurred are extremely important with questions about a technical documentation preparation system.

Please remember that all LQ members are volunteers and not paid support, therefore their participation is voluntary.

Here are some helpful links:
The Welcome to LQ page with some guidance for questions
The Project Tools FAQ which provides further forum usage info and links to help write effective questions
The LQ rules which provides the site rules but also some good guidelines as to how to post

If there are any further questions, the Report action can be used, the Contact Us link at the bottom of the page can be used for questions, or members can private message me with their questions. Singular complaints alone are not always helpful because they do not always explain person's points clearly.

Best Regards.

rnturn 10-01-2022 11:01 AM

Quote:

Originally Posted by marijan (Post 6383449)
Well, in other thread (now closed) should
command be called with \vspc[2] instead of \vspc{2}.

Agreed. Brackets, not braces.

When I threw together a quick-n-dirty LaTeX document (using the 'article' documentclass) and tried the OP's '\vspc' and '\vspc[2cm]' newcommands, I get paragraph spacing of 2cm and 3cm, respectively. Not sure why the spacing but LaTeX (or, rather, TeX) does some intelligent formatting that may be affecting the exact spacing that the OP is looking for. (Especially when you include images, etc.) In the example I slapped together that generated those results, I thought that orphan/widow adjustments may have played a role in the paragraph spacing I wound up with (the resulting PDF had two lines of text on page two). But, removing a few sentences to shorten the paragraphs to produce a one-page output without any orphans or widows showed that this wasn't the case.

OP: Can you generate a PDF of what you're attempting to produce and attach it. Your newcommand is working. Well, it's doing something. Interestingly, '\vspc[0cm]' results in a standard no-blank-lines paragraph spacing.

Is there a reason why you don't simply use '\vspace{1.5}'? If I use that between paragraphs where I want that spacing, I get exactly 1.5cm. Define a newcommand that hard codes the 1.5cm. If that's the standard spacing you want, you can set that using '\setlength{\parskip}{1.5cm}' (which I suspect you already know). Then, for special cases, use '\vspace{custom-amount}'

HTH...


All times are GMT -5. The time now is 02:44 PM.