編輯:

編輯:

平均能量损失

\documentclass[12pt]{article}
\begin{document}
$\underline{a}\sqcap\underline{a}$
$\overline{a}\sqcup\overline{a}$
\end{document}

但我尝试做的

在此处输入图片描述

你能帮我修复它吗?

編輯:

这是怎么回事?有谁能改善这种情况吗?

\documentclass[a4paper,11pt]{article}

\usepackage[svgnames]{xcolor}
\usepackage{mathtools}
\usepackage{tikz}
\usepackage{pgflibraryshapes}
\usepackage{stackengine}

\begin{document}

$\color{red}{\underline{\textnormal{\color{black}{a}}}} \kern3pt \tclap[-1.7pt]{$\sqcap$} \kern3pt \color{red}{\underline{\textnormal{\color{black}{a}}}}$
$\color{red}{\overline{\textnormal{\color{black}{a}}}} \kern3pt \tclap[-.3pt]{$\sqcup$} \kern3pt \color{red}{\overline{\textnormal{\color{black}{a}}}}$

\end{document}

在此处输入图片描述

答案1

Cragfelt 比我快了几分钟,但 TikZ 的方法略有不同。

代码输出

\documentclass{article}
\usepackage{tikz}
\newcommand\moveup[3][]{
\begin{tikzpicture}[baseline=(a.base)]
\node [inner sep=0pt] (a) {#2};
\node [inner sep=0pt,right=1em,anchor=base west] (b) at (a.base east) {#3};
\draw [red,#1] ([shift={(-2pt,-3pt)}]a.base west) -| ([shift={(1pt,2ex+2pt)}]a.base east) -|
               ([shift={(-1pt,-3pt)}]b.base west) -- ([shift={(2pt,-3pt)}]b.base east);
\end{tikzpicture}}
\newcommand\movedown[3][]{
\begin{tikzpicture}[baseline=(a.base)]
\node [inner sep=0pt] (a) {#2};
\node [inner sep=0pt,right=1em,anchor=base west] (b) at (a.base east) {#3};
\draw [red,#1] ([shift={(-2pt,2ex+2pt)}]a.base west) -| ([shift={(1pt,-3pt)}]a.base east) -|
               ([shift={(-1pt,2ex+2pt)}]b.base west) -- ([shift={(2pt,2ex+2pt)}]b.base east);
\end{tikzpicture}}
\begin{document}
Foo \moveup{g}{b} bar \movedown{Lorem}{ipsum}
\end{document}

答案2

像这样?

\documentclass[12pt]{article}
\begin{document}
$\underline{a}\sqcap\underline{a}$ $\to$
$\begin{array}{c|c|c} 
\cline{2-2}
a & & a\\
\cline{1-1}\cline{3-3}
\end{array}$\\ \\
$\overline{a}\sqcup\overline{a}$ $\to$
$\begin{array}{c|c|c} 
\cline{1-1}\cline{3-3}
a & & a\\
\cline{2-2}
\end{array}$
\end{document}

在此处输入图片描述

答案3

采用不同的方法TikZ

在此处输入图片描述

\documentclass[border=2mm,tikz]{standalone}

\newcommand\moveup[2]{%
  \begin{tikzpicture}
    \path[draw=red] (0,0)--node[above=-1.5pt] {#1}(0.25,0)--(0.25,0.25)--(0.5,0.25)--(0.5,0)--node[above=-1.5pt]{#2}(0.75,0);
  \end{tikzpicture}%
}

\newcommand\movedown[2]{%
  \begin{tikzpicture}
    \path[draw=red] (0,0.25)--node[below=-1.5pt] {#1}(0.25,0.25)--(0.25,0)--(0.5,0)--(0.5,0.25)--node[below=-1.5pt]{#2}(0.75,0.25);
  \end{tikzpicture}%
}

\begin{document}

\moveup{a}{a}
\movedown{a}{a}

\end{document}

相关内容