TeX - LaTeX Asked by user4035 on January 15, 2021
I tried to create a checkbox, analogous to
Creating Boxed Check Mark
This woks correctly:
documentclass{article}
usepackage{amssymb}
begin{document}
makebox[0pt][l]{$square$}raisebox{.15ex}{hspace{0.1em}$checkmark$}
end{document}
But when I tried to use a cross symbol instead of checkmark, it is shifted to the bottom:
documentclass{article}
usepackage{amssymb}
begin{document}
makebox[0pt][l]{$square$}{$times$}
end{document}
Why not use the already available boxtimes
?
documentclass{article}
usepackage{amssymb}
begin{document}
$boxtimes$
end{document}
Correct answer by Gonzalo Medina on January 15, 2021
Here is another possibility:
documentclass{article}
usepackage{amssymb,tikz,pdftexcmds,xparse}
tikzset{box/.style={
minimum size=0.225cm,
inner sep=0pt,
draw,
},
insert mark/.style={
append after command={%
node[inner sep=0pt,#1]
at (tikzlastnode.center){$checkmark$}
}
},
insert bad mark/.style={
append after command={%
[shorten <=pgflinewidth,shorten >=pgflinewidth]
(tikzlastnode.north west)edge[#1](tikzlastnode.south east)
(tikzlastnode.south west)edge[#1](tikzlastnode.north east)
}
},
}
makeatletter
NewDocumentCommand{tikzcheckmark}{O{} m}{%
ifnumpdf@strcmp{#2}{mark}=z@%
tikz[baseline=-0.5ex]node[box,insert mark={#1},#1]{};%
fi%
ifnumpdf@strcmp{#2}{bad mark}=z@%
tikz[baseline=-0.5ex]node[box,insert bad mark={#1},#1]{};%
fi%
ifnumpdf@strcmp{#2}{no mark}=z@%
tikz[baseline=-0.5ex]node[box,#1]{};%
fi%
}
makeatother
begin{document}
tikzcheckmark[scale=0.75]{mark}quadtikzcheckmark[scale=0.75]{no mark}quadtikzcheckmark[scale=0.75]{bad mark}
vspace{1cm}
tikzcheckmark{mark}quadtikzcheckmark{no mark}quadtikzcheckmark{bad mark}
vspace{1cm}
tikzcheckmark[scale=2,red]{mark}quadtikzcheckmark[scale=2,red]{no mark}quadtikzcheckmark[scale=2,red]{bad mark}
end{document}
The result:
Answered by Claudio Fiandrino on January 15, 2021
Another option:
makebox[0pt][l]{$square$}{raisebox{0.1height}{$times$}}
(use raisebox
as in the first symbol you use)
Answered by ebondrow on January 15, 2021
Another option:
use XBox
with the wasysym
package
Answered by user95439 on January 15, 2021
Here is an alternative with l3draw
.
documentclass{article}
usepackage{enumitem}
usepackage{xcolor}
usepackage{l3draw,xparse}
ExplSyntaxOn
%---------------------------------------------------------
NewDocumentCommand{xpboxedtimes}{O{1ex}O{black}}
{
fp_set:Nn l__xp_boxed_line_width_fp { 0.08ex }
raisebox{0pt}[#1][0pt]{color{#2}xp_boxedtimes:n { #1 }}
}
NewDocumentCommand{xpboxedempty}{O{1ex}O{black}}
{
fp_set:Nn l__xp_boxed_line_width_fp { 0.08ex }
raisebox{0pt}[#1][0pt]{color{#2}xp_boxedempty:n { #1 }}
}
dim_new:N l__xp_boxed_size_dim % dimension of the box
fp_new:N l__xp_boxed_line_width_fp %linewidth set to 0.08ex by default
cs_new_protected:Nn xp_boxedtimes:n
{
dim_set:Nn l__xp_boxed_size_dim { #1 }
draw_begin:
draw_linewidth:n { l__xp_boxed_line_width_fp }
draw_path_moveto:n { 0l__xp_boxed_size_dim , 0l__xp_boxed_size_dim }
draw_path_lineto:n { 1l__xp_boxed_size_dim , 0l__xp_boxed_size_dim }
draw_path_lineto:n { 1l__xp_boxed_size_dim , 1l__xp_boxed_size_dim }
draw_path_lineto:n { 0l__xp_boxed_size_dim , 1l__xp_boxed_size_dim }
draw_path_close:
draw_path_use_clear:n { stroke }
draw_path_moveto:n { 0l__xp_boxed_size_dim , 1l__xp_boxed_size_dim }
draw_path_lineto:n { 1l__xp_boxed_size_dim , 0l__xp_boxed_size_dim }
draw_path_use_clear:n { stroke }
draw_path_moveto:n { 0l__xp_boxed_size_dim , 0l__xp_boxed_size_dim }
draw_path_lineto:n { 1l__xp_boxed_size_dim , 1l__xp_boxed_size_dim }
draw_path_use_clear:n { stroke }
draw_end:
}
cs_new_protected:Nn xp_boxedempty:n
{
dim_set:Nn l__xp_boxed_size_dim { #1 }
draw_begin:
draw_linewidth:n { l__xp_boxed_line_width_fp }
draw_path_moveto:n { 0l__xp_boxed_size_dim , 0l__xp_boxed_size_dim }
draw_path_lineto:n { 1l__xp_boxed_size_dim , 0l__xp_boxed_size_dim }
draw_path_lineto:n { 1l__xp_boxed_size_dim , 1l__xp_boxed_size_dim }
draw_path_lineto:n { 0l__xp_boxed_size_dim , 1l__xp_boxed_size_dim }
draw_path_close:
draw_path_use_clear:n { stroke }
draw_end:
}
%---------------------------------------------------------
ExplSyntaxOff
begin{document}
{xpboxedtimesquad xpboxedempty}
begin{itemize}[label={xpboxedtimes[1ex][red]},leftmargin=*]
item test
item test
item test
end{itemize}
end{document}
Answered by azetina on January 15, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP