In my country, the base of logarithm is written in superscript before the log sign, i.e. $^a\log b$
means log base a
of b
. This doesn't look nice on LaTeX, because there is a gap between ^a
and \log
. How to remove this gap?
[Tex/LaTex] Customized log notation
math-operatorsspacing
Related Solutions
Currently, I solved the problem by a small workaround but better / correct solutions are welcome. The workaround has been proposed by matheburg. Thanks for that!
Instead of $K_{-1}$
, I now use $K_{\!^{\_}1}$
. It sounds weird, but it looks similar to the minus sign. The underline is visible, so that I add an invisible negative space \!
and take the underline \_
as superscript.
You shouldn't be using \left
and \right
to begin with. Instead, I suggest you use \bigl[
and \bigr]
for both terms, as follows:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
V = \int_0^2(4-x^2)\,dx
= 4\int_0^2\!dx - \int_0^2\!x^2\,dx
= 4\bigl[x\bigr]_0^2 - \bigl[\tfrac{1}{3}x^3\bigr]_0^2
\]
\end{document}
Addendum: It may be instructive to compare and contrast four different ways of typesetting the evaluated integrand, as is done in the middle four rows of the following screenshot. IMNSHO, the \bigg
-sized square brackets are needlessly large; in fact, they dominate visually to an extent that the material they enclose is dwarfed and overwhelmed by the square brackets themselves. A much better typographic balance is struck by the \big
-sized square brackets; cf the next-to-last row in the screenshot. Of the two solutions that use a single vertical bar, I'd say the \Big
-sized solution is far better than the \bigg
-sized solution. Put differently, I see absolutely no (typographic) reason for why the brackets (or bars) should be as tall as the integral symbols.
\documentclass{article}
\usepackage{amsmath} % for 'align*' environment and `\tag*` macro
\begin{document}
\begin{align*}
V &= \int_0^2(4-x^2)\,dx = 4\int_0^2\!dx - \int_0^2\!x^2\,dx \\[1ex]
&= 4\biggl[x\biggr]_0^2 - \biggl[\frac{1}{3}x^3\biggr]_0^2
\tag*{pair of \texttt{bigg} square brackets}\\[2ex]
&= 4 x\biggr\rvert_0^2 - \frac{1}{3} x^3\biggr\rvert_0^2
\tag*{single \texttt{bigg} vertical bar}\\[2ex]
&= 4 x\Bigr\rvert_0^2 - \tfrac{1}{3} x^3\Bigr\rvert_0^2
\tag*{single \texttt{Big} vertical bar}\\[2ex]
&= 4\bigl[x\bigr]_0^2 - \tfrac{1}{3}\bigl[x^3\bigr]_0^2
\tag*{pair of \texttt{big} square brackets}\\[1ex]
&= 4(2-0)-\tfrac{1}{3}(8-0)=\tfrac{1}{3}(24-8)=16/3.
\end{align*}
\end{document}
Second addendum, prompted by a follow-up comment by the OP that if "a bracket pair appears in math-mode, [and if the] closing bracket [is followed by] both superscript and subscript [terms], then it should be automatically rendered using the big brackets style."
It would be a lot of work, to put it politely, to program pdfLaTeX to automatically recognize all instances of [ ... ] _ {...} ^ {...}
in a document and to process them according to your preferences. Your objective may be achieved more easily, though, if you can run LuaLaTeX: One would simply set up a Lua function that makes use of Lua's powerful string-handling functions. (The main syntactic convention is that the subscript and superscript terms must be encased in curly braces. The subscript and superscript terms may be empty, i.e, [x]_{}^{}
will be recognized by the Lua function and processed correctly.) The Lua function is assigned to a certain Lua callback that makes it act like a pre-processor on the input. That way, TeX itself never "sees" the original code from the input file; instead will only see something that contains \biggl[
and \biggr]
directives.
That said, I think you'd be even better off setting up a dedicated LaTeX macro called, say, \inteval
, and to edit the math material to make use of this macro. A nice aspect of this approach is that while the default size of the square brackets would be "\bigg, one could provide an option to override the default and to specify a size of
\big,
\Big, or
\Bigg`. Both possibilities are examined in the following screenshot and associated code. Whichever way you pursue, I recommend you add a bit of whitespace padding inside the enclosing square bracket and to snug up the sub- and superscript terms to the right-hand square bracket.
% !TeX program = lualatex
\documentclass{article}
%% LaTeX macro called "\inteval
\newcommand\inteval[4][bigg]{%
\csname #1l\endcsname [ \mkern1.5mu #2 \mkern1.5mu%
\csname #1r\endcsname]_{\mkern-2mu#3}^{\mkern-2mu#4}%
}
\usepackage{amsmath} % for 'align*' environment
\usepackage{luacode}
%% Lua-side code: Set up a Lua function called 'int_eval'
\begin{luacode}
function int_eval ( s )
return ( string.gsub ( s ,
"(%b[])%s-_%s-(%b{})%s-%^%s-(%b{})" ,
function ( a, b, c)
a = "\\biggl[\\mkern1.5mu" .. string.sub(a,2,-2)
.. "\\mkern1.5mu\\biggr]"
b = "_{\\mkern-2mu" .. string.sub(b,2,-2) .. "}"
c = "^{\\mkern-2mu" .. string.sub(c,2,-2) .. "}"
return (a..b..c)
end ) )
end
\end{luacode}
%% TeX-side code: Assign the Lua function to the 'process_input_buffer'
%% callback to make it operate like a preprocessor on the entire input.
\AtBeginDocument{\directlua{luatexbase.add_to_callback(
"process_input_buffer", int_eval , "int_eval" )}}
\begin{document}
\begin{align*}
\int_0^2\!(4-x^2)\,dx
&= 4[x]_{0}^{1} - [\frac{x^3}{3}] _ {0} ^ {2} \\[1ex]
&= 4\inteval{x}{0}{2} - \inteval{\frac{x^3}{3}}{0}{2}
= 4\inteval[big]{x}{0}{2} % note use of "big" option
- \inteval{\frac{x^3}{3}}{0}{2} \\[2ex]
\int_0^X \!\!\frac{1}{3+t}\,dt
&= [\ln(3+t)] _{0} ^ {X} \\[1ex]
&= \inteval{\ln(3+t)}{0}{X} % no optional sizing argument
= \inteval[Big]{\ln(3+t)}{0}{X} % note use of "Big" option
\end{align*}
\end{document}
Best Answer
You can use a negative space
\!
to remove (or reduce) this to your liking. It would be best to define a command for this, for the sake of consistency:Of course, more specific kerning is also possible using
\kern
.The above MWE defined
\Log[<base>]
that takes an optional argument<base>
. Without<base>
it defaults to\log
.