LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-28-2022, 03:29 PM   #1
Faki
Member
 
Registered: Oct 2021
Posts: 574

Rep: Reputation: Disabled
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.

Last edited by Faki; 09-29-2022 at 01:55 PM.
 
Old 09-28-2022, 04:24 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by Faki View Post
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 View Post
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 View Post
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 View Post
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.
 
4 members found this post helpful.
Old 09-29-2022, 01:39 PM   #3
marijan
LQ Newbie
 
Registered: Aug 2013
Posts: 13

Rep: Reputation: Disabled
Well, in other thread (now closed) should
command be called with \vspc[2] instead of \vspc{2}.
 
Old 09-29-2022, 01:56 PM   #4
Faki
Member
 
Registered: Oct 2021
Posts: 574

Original Poster
Rep: Reputation: Disabled
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.
 
Old 09-30-2022, 01:22 PM   #5
marijan
LQ Newbie
 
Registered: Aug 2013
Posts: 13

Rep: Reputation: Disabled
I wouldn't know about it. I am mostly lurking here once in a week. I hope I helped with the latex.
 
Old 09-30-2022, 04:26 PM   #6
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by Faki View Post
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.
 
1 members found this post helpful.
Old 09-30-2022, 09:41 PM   #7
marijan
LQ Newbie
 
Registered: Aug 2013
Posts: 13

Rep: Reputation: Disabled
Quote:
Originally Posted by computersavvy View Post
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.
 
Old 10-01-2022, 09:42 AM   #8
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by Faki View Post
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.
 
Old 10-01-2022, 11:01 AM   #9
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by marijan View Post
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...
 
  


Reply

Tags
latex, spacing



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LaTeX forum / Where to ask LaTeX questions? max_sipos Linux - Software 2 12-21-2011 12:01 PM
need help spacing out cells in a latex table hedpe Programming 2 02-15-2007 03:59 PM
kde 3.4.2 vertical icon spacing babag Mandriva 0 11-19-2005 02:57 AM
Line/Vertical Spacing problem(Possibly because of CJK?) CircleSoft Linux - General 0 11-07-2004 01:09 AM
Latex Help - Tabular creating vertical holes in table maneeshsethi Linux - Software 3 08-20-2004 08:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration