4
votes
1answer
45 views

Arbitrary positioning in math mode without size restriction

In the MWE below, are all general methods, of achieving arbitrarily shifting of symbols up or down or left or right in math mode, represented? If yes, that is the answer. If no, what good methods are ...
2
votes
1answer
42 views

Unwanted vertical space/glue between consecutive custom \section macro calls

I am using XeTeX. I need to redefine the \section and \subsection commands in order to use some macros which don't behave well with the titlesec and/or sectsty packages. I found some code to do ...
9
votes
1answer
140 views

Acceptable use cases for xspace; When will it fail?

I have used xspace for a long time to take care of adding space after usage of some macros. Usually, it is with a macro to format a word consistently, as in: \documentclass[]{article} ...
16
votes
2answers
173 views

Why is unskip not working here?

I'm trying to define a macro to be used as follows: \usepackage[normalem]{ulem} \newcommand{\thesis}[1]{\uline{\ignorespaces #1\unskip}} % underlining required by school - I know, I know % later... ...
3
votes
1answer
62 views

Make a command start new line in a list if it is not currently at the end of another list

I am trying to typeset a structured proof as demonstrated by Leslie Lamport in his paper How to Write a 21st Century Proof. In particular, I am trying to typeset Figure 3 (shown below). My code and ...
5
votes
1answer
41 views

Using \newcommand to format numbers/strings according to a pattern [duplicate]

I'm an aspiring LaTeX user and have so far managed the first steps and created my first few documents. Coming from a programming background I've been wondering how you could use \newcommand to create ...
6
votes
3answers
368 views

Adding vertical space (\vspace) around custom environment

I have document with custom environment myenv which left margin is 4em. \documentclass{book} \usepackage{lipsum} \newenvironment{myenv}{ \setlength{\leftskip}{4em} } \begin{document} \lipsum[1-2] ...
7
votes
1answer
81 views

Reversing the effect of a \newline with the next command?

I'm using the harvard package and the agsm bibliography style. I'm aware that there are alternatives, e.g., natbib plus har2nat, and I will be looking into those in the not-too-distant future, but at ...
2
votes
0answers
126 views

Using the correct amount of space around unit symbols

This is from an old package I developed back in 2003. The idea was to cover international system units (SI) and other type of units, roughly following guidelines from that document. Units should ...
1
vote
0answers
102 views

Vertical spaces around display math

(First of all, I know that \[ \] should be used instead of $$ $$ and I do it.) I'd like to know about the vertical spacing around math display blocks. According to texdef -t latex \[ we have \[: ...
4
votes
2answers
200 views

Making aliases for variables

I'm trying to figure out how best to define an alias. I have some moderately complicated variable names, such as $p^{i,j}_{t}$, and having to type them over and over again is a pain. More importantly, ...
2
votes
0answers
50 views

How to insert a space after a substitution of a variable or a command? [duplicate]

I am trying to learn how to define commands (\newcommand) and variables (\def) in LaTeX. When I try: \def \new {$new$} or \newcommand{\new}{$new$} and substitute it in the text: ...
4
votes
1answer
54 views

Blank Space in Tex Macro Definition

I would like to implement a queue in the following way. A macro (variable?) \queue holds a string that may contain dots. Substrings separated by dots are the elements of the queue. Hence, the string ...
3
votes
1answer
195 views

Using \parbox in \resizebox

I tried resizing a \parbox-d text into a 5cm x 5cm square box (without keeping the aspect ratio). The output is absolutely strange to me, even if I don't specify the height. Couldn't find the ...
3
votes
2answers
77 views

Determining spacing by a number that is a multiple of a counter

I have \hspace and I have a stepcounter xyz \documentclass[12pt]{article} \usepackage[top = 1in, bottom = 1in, left = 1in, right = 1in]{geometry} \usepackage[T1]{fontenc} ...
4
votes
4answers
275 views

How to repeat text

I get interesting errors with the following macro. Mostly it works, but I get extra spaces after \noindent (but not after \newline). I tried using \loop or \whiledo (from ifthen) but get stack ...
2
votes
1answer
185 views

how to use tags or symbols in latex? [duplicate]

I am writing report using Latex software but I got stuck while using tags. consider a statement( for example): for any A ∈ Γ, B ⊆ A implies B ∈ Γ. The traditional (t, n) threshold secret sharing ...
14
votes
1answer
225 views

Eating space before a command

If I have a \newcommand*{\foo}{foo} it will 'eat' space after it. Is there a way to tell it to eat space before, so that the result of e.g. bar \foo bar would be 'barfoobar'?
13
votes
1answer
94 views

Long command name for horizontal space ~

The short command \, has (more or less) the long command equivalent \thinspace. - What is the long command for the unbreakable space ~? Also, is there a long command for a space which is *just a ...
8
votes
1answer
464 views

Why does \vfill not work inside minipage?

Perhaps the answer is trivial, and I am facing the scenario as part of a larger macro. I faced a situation where I found that \vfill does not work inside minipage environment. The extracted code from ...
2
votes
1answer
79 views

How can I influence the spacing of mathematical functions by an own macro?

I would like to get a macro \of to define a function with an optional macro \at to define its restriction. The reason is, that I don't like the spacing for functions (as there is no spacing) and I ...
1
vote
1answer
62 views

Spacing in commands for math mode

I would like to define commands with semantics similar to e.g. + in math mode. For instance, $(x+y)$ produces an equation with some spacing around +, whereas $(+)$ produces an equation with less ...
11
votes
4answers
108 views

A question about macro matching

Consider the following macro definition, and subsequent invocation: \def\foo #1 #2 \bar{stuff with #1 and #2 goes here} \foo arg1 arg2 \bar The \bar simply acts as the terminator for \foo. This all ...
9
votes
1answer
205 views

How to define commands that do not consume any space

I want to create an environment that generates special tables and graphs. Inside the environment the user should be able to execute predefined commands that either modify the behavior of the final ...
12
votes
3answers
426 views

Multiple letters without spacing in Math [duplicate]

Is there something I can add to the preamble of my document such that multiple letters without spacing in a Math environment (such as $NP$) do not have extra spacing between them and are not ...
9
votes
2answers
187 views

Is it possible to define an environment that might not be displayed?

I am currently improving lecture notes for technical computer science. The lecture notes are printed. Chapters in those notes begin on the right side, so it might happen that one page is completely ...
13
votes
2answers
4k views

When should you use \vskip (\hskip) rather than \vspace (\hspace) in a LaTeX document?

I assume that, to guard against strange errors, you should use \vspace rather than \vskip whenever possible in a LaTeX document. But are there any situations in which you must use \vskip? I'm ...
13
votes
1answer
181 views

How to make \newcommand with one argument that does nothing.

I am writing a document with extra notes intended only for myself. \newcommand{\mycomment}[1]{\emph{Note: #1}} %\newcommand{\mycomment}[1]{} When I wish to remove the extra comments, I simply ...
8
votes
2answers
92 views

Eat double space

How can I get a command to eat an unnecessary space, consider the below: \documentclass{article} \newcommand{\mycommand}[1]{#1} \begin{document} %Creates single spaces Discussed ...
1
vote
2answers
198 views

Spacing depending on optional subscripts and superscripts

I am totally new to LaTeX (use it for 2 days), so I am sorry if this has already been asked, but I spent the last 6 hours searching for a solution, but to no avail. (I stumbled upon a package xpeek ...
6
votes
2answers
245 views

Custom verbatim that sets all spaces (“ ”) as visible spaces (“␣”) that can line-break

It makes sense to typeset code in a monospaced font. Sometimes such code needs to be embedded in a paragraph context, and then it will be useful to allow it to linebreak. In order to visualize spaces ...
2
votes
2answers
127 views

Kind of spurious space

I'm trying to write a \spaced macro: it takes a string as parameter, decompose that string and then recompose it spreading avery token from the others according to a given \spreadratio. Here are the ...
4
votes
1answer
174 views

Add \par only if last paragraph did not end with displayed math

Background: I have named "sections" (sections for rest of this question) which are conditionally displayed or suppressed based on parameters. To simplify the test case below, these are controlled by ...
3
votes
1answer
116 views

Vertical spacing problem with multicol package and a newcommand

The following code produces and unwanted space. Why and how can it be avoided? A redefinition of the command or macros are invited. \documentclass[letterpaper]{article} ...
0
votes
0answers
56 views

How to avoid having to use the tilde with every macro? [duplicate]

I am relatively new to LaTeX, so please bear with me. I have just started using macros and finding them quite useful. However, I find myself having to use the tilde (~) a lot of times to get a space ...
2
votes
1answer
176 views

Use headings in letters / vertical space

I need to use headings in a letter, more precisely in documentclass dinbrief. Knowing that LaTeX does not support section or subsection commands in this document class I use the following workaround: ...
1
vote
0answers
70 views

Text in command gets glued to following text [duplicate]

I made this command \newcommand{\BR}{MyBrand\superscript{\scriptsize ™}}, when I use it and write something like this \BR is awesome the ouput is: MyBrand™is awesome What am I doing wrong here?
6
votes
1answer
687 views

Applying condition around \intertext and \shortintertext leaves excess vertical space

When I try to make either \intertext or \shortintertext conditional I get excess vertical spacing prior to the conditional text as per the MWE below. Note the excess vertical spacing prior to "Albert ...
9
votes
3answers
237 views

I want to create a command that will conditionally gobble up trailing whitespace: I want an “\unxspace” command

I have a command that occasionally produces whitespace that I don't want. \def\testa{a} \def\testb{a} \newcommand{\mycommand}[1]{\ifx\testa\testb{#1}\fi} When \testa and \testb are different, I ...
4
votes
3answers
231 views

How are space tokens and empty lines processed by long commands (as their potential arguments)?

How are spaces and empty lines processed by long commands (i.e., those that do not accept paragraph breaks inside)? Are there different space tokens aside from " " and an empty line? It appears that ...
16
votes
4answers
501 views

Do starred commands eat up space after them?

Do starred commands eat up spaces after them, like unstarred ones do? That is, is \somecommand* nextword equivalent to \somecommand*nextword? And: Does it depend on the particular way a starred ...
8
votes
1answer
288 views

Why do we have something like “-3.5ex \@plus‎ -‎1ex \@minus‎ -‎.2ex” instead of a fixed value? [duplicate]

Possible Duplicate: What is glue stretching? In the book class, we have the following. ‎\newcommand\section{\@startsection {section}{1}{\z@}%‎ ‎{-3.5ex ...
6
votes
1answer
83 views

Command analogous to \afterpage, but for lines instead of pages

Sometimes I would like to tell latex to do something after it finishes the line currently being typeset. For example, one might want to use the command \needspace{4\baselineskip} (assuming the ...
10
votes
3answers
3k views

How to change dot spacing in \dotfill?

I'm using the \dotfill command in a nomenclature to add units at the end of each line. Here is the code I'm using: \usepackage[refpage]{nomencl} \newcommand{\nomunit}[1]{% ...
8
votes
2answers
268 views

How can I remove leading and trailing spaces from a macro argument?

Consider this minimal working example: \documentclass[a4paper]{amsart} \usepackage{tikz} \tikzset{graph/.style = {every node/.style = { draw, shape = ...
4
votes
1answer
186 views

Unmodified Source Code

I have a macro that helps me print out(or do anything really) source code in various ways using lua: see: `xparse verbatim` with `newline` The macro is \def\SourceCode{% \begingroup% ...
10
votes
2answers
211 views

Trimming whitespace around text (like LTRIM, RTRIM and TRIM)

When working in Excel with text strings, it is convenient to use the LTRIM, RTRIM and TRIM functions which removes white space around text string. What would be an efficient way of duplicating this in ...
2
votes
0answers
514 views

How can I remove the blank space before and after a command [closed]

I create a command, \newcommand{\cmd}{b} but when I use this command a\cmd{}c What I get is a b c but what I want is abc How can I remove two blanks?
11
votes
2answers
443 views

Ignoring space between empty/optional command arguments

(This may be a duplicate, but I could not find an answer among the pile of similar questions...) Suppose we have the following command: % <month> <year> <month> <year> ...
6
votes
1answer
772 views

Remove spaces after a custom definition

As scientific species names should be written in italic, I have adopted a shortcut to do this in LaTex by creating a definition in the preamble: \def\GM{{\it Gadus morhua~}} Then it's easy to call ...