1

MWE

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

but what I try to do

enter image description here

Can you help me fix it?

Edited:

How did this happen? And Is there anyone who can make it better?

\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}

enter image description here

2

Cragfelt beat me by a couple of minutes, but a here is a slightly different approach with TikZ.

output of code

\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}
  • I beat you by minutes but you did it by accuracy. Nice answer! :-) – Cragfelt Nov 25 '17 at 23:41
2

Like this?

\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}

enter image description here

  • Nice alternative solution. – Özgür Nov 24 '17 at 19:37
2

A different approach with TikZ

enter image description here

\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}
  • I learned new information from the code you wrote. But I will accept the other answer. – Özgür Nov 25 '17 at 9:10
  • Do not worry @Özgür. I am glad it helped you anyway. Torbjorn's answer is way more accurate. – Cragfelt Nov 25 '17 at 23:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.