TeX - LaTeX Asked by user100361 on June 9, 2021
Sometimes I create ad-hoc macros in the middle of my document for various reasons. However, the definitions sometimes cause extra space to be inserted. My questions are:
Here is an example:
documentclass[varwidth]{standalone}
begin{document}
Lorem ipsum sit amet. Lorem ipsum dolor sit amet.
Lorem ipsum
newcommanddolor{dolor}
sit amet. Lorem ipsum dolor{} sit amet.
end{document}
You are inserting two spaces: one before the definition and one after it (the new lines at the end).
Lorem ipsum %<--- end of line = space
newcommanddolor{dolor} %<--- end of line = space
sit amet. Lorem ipsum dolor{} sit amet.
Normally tex merges two spaces into one, but the newcommand
prevents this as you now have <space><something><space>
, and not simply <space><space>
, even if the <something>
doesn't led to some visual output.
Suppress one of the spaces with %:
Lorem ipsum
newcommanddolor{dolor}%
sit amet. Lorem ipsum dolor{} sit amet.
Or better move the `newcommand to a better place. Using that in the middle of a paragraph leads to messy code.
Correct answer by Ulrike Fischer on June 9, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP