gpt-4-0314· OpenAI
WildChat-4.8M (AI2)
revtex 让equation 紧贴文字
- User
revtex 让equation 紧贴文字
- Assistant
在 revtex 模板中,可以通过调整公式之前的空间,将等式与文本紧贴。首先需要使用调用 \usepackage{etoolbox} 宏包,然后使用 \before_resuming 环保进行修改:
\documentclass[aps,groupedaddress,showpacs, twocolumn, pra]{revtex4-1} \usepackage{etoolbox} % Custom space before equations \newlength{\stoca} \newcommand{\myvphantom}[1]{\setlength{\stoca}{\dimexpr\ht\strutbox-#1\relax}\vspace{\stoca}} % Hook resetting the custom space for any documentclass \AtBeginDocument{ \setlength{\stoca}{6pt} % Default is 6pt (taken from amsmath.sty) \pretocmd{\align@preamble}{\myvphantom{-\stoca}}{}{\undefined} \pretocmd{\start@gather}{\myvphantom{-\stoca}}{}{\undefined} \pretocmd{\start@multline}{\myvphantom{-\stoca}}{}{\undefined} \pretocmd{\[:}{\myvphantom{-\stoca}}{}{\undefined} \pretocmd{\equation}{\myvphantom{-\stoca}}{}{\undefined} } % Test \begin{document} 你好,这是用来测试公式与文字紧贴的一个例子:\\ \begin{equation} a^2 + b^2 = c^2 \end{equation} 你好,这是用来测试公式与文字紧贴的一个例子:\\ \begin{equation} a^2 + b^2 = c^2 \end{equation} \end{document}希望能够满足您的需求!
- User
BufWritePre *.cpp lua vim.lsp.buf.formatting_sync(nil,1000) rewrite with lua grammar
- Assistant
您的需求看起来是希望在保存
*.cpp文件之前运行 Lua 编写的 Vim LSP 格式化同步。为了实现这个功能,您可以在您的init.lua(如果您使用的是 NeoVim)或者vimrc文件中添加如下的配置:如果您使用 NeoVim:
-- 在 init.lua 文件里面加入下面这段代码 vim.api.nvim_command('autocmd! BufWritePre *.cpp lua vim.lsp.buf.formatting_sync(nil,1000)')如果您使用 Vim:
" 在 vimrc 里面加入下面这段代码 autocmd! BufWritePre *.cpp call luaeval("require('vim.lsp.buf').formatting_sync(nil,1000)")在以上代码中,我们使用了
autocmd在保存*.cpp文件之前触发vim.lsp.buf.formatting_sync(nil,1000)。这样,每当保存一个 cpp 文件时,格式化就会自动触发,并且在1000ms内同步完成。