Tag Info

Hot answers tagged

24

put it into braces {...}, then it will be a math atom and not broken at the end of the line. ${v_{initial} = \SI{1000}{m/s}}$ the prevent an overfull box use \sloppy: \documentclass{article} \usepackage{siunitx} \begin{document} {\sloppy A text with an inline equation which is broken in to two parts but is not wanted right here ${v_{initial} = ...


21

I think you can justly regard this strange behaviour as kind of a bug in TeX's sub- and superscript positioning algorithm; it doesn't make sense that both the sub- and the superscript are raised. See below for some suggestions on how to fix the problem. At the end I offer a new positioning algorithm, and I compare it with the old algorithm. (Sorry for the ...


15

I'm sure you are looking for the holtpolt package and its command \polter, like in the following example: \documentclass{standalone} \usepackage{holtpolt} \begin{document} \[ a_0+\polter{1}{a_1}+\polter{1}{a_2}+\cdots+\polter{1}{a_n}+\cdots \] \end{document}


14

A couple of versions, you probably need to fiddle with the spacing to get exactly what you need but: \documentclass{article} \def\cFrac#1#2{% \begin{array}{@{}c@{}}\multicolumn{1}{c|}{#1}\\% \hline\multicolumn{1}{|c}{#2}\end{array}} \def\cFracB#1#2{% \vcenter{\hbox{\strut$#1$\,\vrule}\hrule\hbox{\strut\vrule\,$#2$}}} \begin{document} $ A + ...


13

TeX features a special primitive for this very case. However, you will have to specify code for all four math styles: \mathchoice{display}{text}{script}{scriptscript} See TeX by Topic for more information.


13

You can directly tell where the baseline should meet the picture using the baseline option \documentclass{article} \usepackage{tikz} \begin{document} the distance \tikz[baseline=-0.5ex]{ \draw [|-|] (0,0) -- (5ex,0); } overarching the activities \end{document}


13

The default positions of sub and superscripts are closer to the baseline in textstyle as TeX tries to maximise the chance that the expression does not disturb the paragraph line spacing. Your first example is the standard setting for inline math, however with the larger scripts caused by the subscripting, TeX has to move them further apart. This is ...


12

I'm not sure if this is a good idea or not (imagine a new reader searching for equation 2.1, for example), but the following seems to do what you want; note that I've used refstepcounter to increment the equation counter. \documentclass{article} \usepackage{amsmath} \begin{document} The equation $a+1=b~\refstepcounter{equation}(\theequation)\label{myeq}$ ...


12

Using ${....}$ does indeed prevent a formula from being broken across lines but at the cost that you freeze up all spacing within the formula at its natural width. If you write $a=b+c$ then LaTeX generates the following list for you: \mathon \OML/cmm/m/it/10 a \glue(\thickmuskip) 2.77771 plus 2.77771 \OT1/cmr/m/n/10 = \penalty 500 \glue(\thickmuskip) ...


11

Images are added with a zero depth, i.e. they sit on the baseline. It depends very much on the situation (and personal taste) what the "ideal" placement of a particular image is. So no, there is no way to automatically get-it-just-right (TM). Note that \raisebox allows the use of \height, \depth, \width and \totalheight (=height+depth) which represent the ...


10

Here is one way to do it. I took the liberty to add some formatting, but feel free to change it as you wish: \documentclass{article} \usepackage{amsmath} \usepackage{tikz} \newcommand*{\WineMenuColor}{black}% \newcommand*{\StartMenu}{\includegraphics[scale=0.2]{StartIcon}}% \newcommand*{\WinMenu}[1]{% \StartMenu % \foreach \x in {#1} {% ...


10

I was a little bit surprised to discover that this wasn't already catered for by the fancyvrb package. When using that package, the problem would appear to be because the newline character is defined to be an outer macro, which can't then be gobbled into the verbatim command. So here's a little modification that defines a command \VerbLB which converts ...


10

The following defines \inlineequation: \inlineequation[<label name>]{<equation>} Optionally <label name> can be given for referencing the equation. \label afterwards keeps the previous referencing behavior like an environment equation would have done. \refstepcounter is called at the beginning of the inline equation, because package ...


9

aligned is intended for this. But also align works if you use \parbox: Text $\displaystyle\parbox{2cm}{\begin{align} x &= 1 \\ y &= 0 \end{align}}$ \quad more text


9

Taking the definitions you make in the other question, here's a way: \mathchoice has four arguments, stating what's to be done in the various situations; \mathop states how the symbol should be considered with respect to spacing and ending with \displaylimits ensures the same behavior as \sum: \documentclass{article} \usepackage{tikz} \newcommand{\osum}{ ...


9

You need to run this twice \documentclass{article} \usepackage{color} \makeatletter \def\savepos#1{\leavevmode\pdfsavepos\write\@auxout{% \gdef\string\save@#1{{\the\pdflastxpos sp }{\the\pdflastypos sp }}}} \def\xx#1{\expandafter\expandafter\expandafter\@firstoftwo\csname save@#1\endcsname} ...


8

Anything you enclose within an \hbox or the equivalent LaTeX \mbox will not break. However overflowing into the margins is not a good idea. In the minimal below you can see the effect by using the geometry package to show a border around the normal text area. \documentclass{octavo} \usepackage[showframe=true]{geometry} \begin{document} \mbox{This is an ...


8

There are some strategies that you could use: enclosing the expression inside braces, or boxing it, but in some cases this can produce overfull boxes. Most of the times the best solution is to rephrase the text where the formula appears so that a line break doesn't occur. An example where things go right: \documentclass[draft]{article} \begin{document} ...


8

Token register method The problem is that the list environment is not too happy, if \item is put inside a group. \foreach of pgffor puts the body inside groups. The following file uses a token register to collect the body of the environment. \Choice needs to be expanded once. \documentclass{article} \usepackage[inline]{enumitem} \usepackage{pgffor} ...


7

There is some glue in \:, but not in \!: the first uses \medmuskip which is 4.0mu plus 2.0mu minus 4.0mu, the second \thinmuskip which is 3.0mu. To avoid the glue use only \! or, simpler, just \mkern: \documentclass[a5paper]{article} \newcommand{\md}{\ensuremath{M\mkern-9mu D}} \begin{document} a a a a a a a a a a a a a a a a a a a a a a $\md$ a a a a ...


6

AFIK this is an area, where you cannot use Pygments. The simplest way to achieve it from a "typing" point of view is to use a "short verbatim". \documentclass{article} \usepackage{fancyvrb} \DefineShortVerb{\|} \begin{document} This is some inline code |for i=1;i<20;i++| and more \ldots \end{document} The package fancyvrb offers a number of ...


6

You could use TikZ for this. Somewhere at the start of the document, issue \tikzset{ every picture/.style={ remember picture, % Make nodes available to all TikZ pictures inner xsep=0pt, % Remove horizontal padding inner ysep=1pt, % Set small vertical padding baseline, % Align TikZ pictures at the baseline ...


6

I use a solution to this problem that cannot be used always. Once I finish my work, I go thru the "almost-final" version of the whole paper and when an inappropriate break appears (inside equation, stupidly-broken name/date/... that does not look good in my opinion), I rephrase the text so that this piece appears in the middle of the line. Actually, you have ...


6

The following MWE provides \lstInline[<options>]{<code snippet>} as a complement to \lstinline that tests whether the in-line code will fit within the remainder of the line, otherwise it issues a line break. \documentclass{article} \usepackage{showframe}% http://ctan.org/pkg/showframe \usepackage{linegoal}% http://ctan.org/pkg/linegoal ...


6

A verb-like construction \path from url or hyperref package can work with line breaks: \documentclass{article} \usepackage[obeyspaces]{url} \begin{document} \path{foo = function (bar, baz);} \end{document} Note obeyspaces option


6

You may try this, which seems shorter than Heiko's: \documentclass{article} \usepackage[inline]{enumitem} \usepackage{xparse} \newlist{MyHChoices}{enumerate*}{2} \setlist*[MyHChoices]{label=\Alph*., itemjoin={\hspace*{2.0em}}} \ExplSyntaxOn \NewDocumentCommand{\InlineList}{ m } { \begin{MyHChoices} \clist_map_inline:nn { #1 } { \item ##1 } ...


6

Using inline math is so wrong for this (but I say same every time you post an example). However if you must, you must... \documentclass{article} \usepackage[a6paper,vmargin=15mm,hmargin=5mm]{geometry} \usepackage{times} \usepackage{helvet} \usepackage{courier} \usepackage[T1]{fontenc} \usepackage{mathtools} \allowdisplaybreaks \usepackage{tcolorbox} ...


5

It sounds as if you want to detect not a particular environment but the current math style. The \mathchoice primitive is appropriate here: \documentclass{article} \usepackage{amsmath} \newcommand*{\mymacro}{\mathchoice{A}{B}{C}{D}} \begin{document} $ \mymacro_{\mymacro} $ \begin{align} \mymacro \end{align} \[ \mymacro \] \end{document} The four cases ...


5

$x_1$,~$x_2$, \dots,~$x_n$ is OK. This is how Knuth use in TeXbook. For me, I would replace the tildes with spaces. I don't think one should use ... instead of \dots or \ldots.


5

The enumitem package offers the option to typeset inline lists using enumerate* \documentclass{article} \usepackage[inline]{enumitem} \begin{document} \begin{enumerate*} \item one \item two \end{enumerate*} \end{document} You can customize the joining text using itemjoin. Edit: Here's a mock-up of your MWE: \documentclass{article} ...



Only top voted, non community-wiki answers of a minimum length are eligible