Cartouche 文本框

Cartouche 文本框

如何使用“Tikz 包”或任何其他方法(如果有比使用 Tikz 包更简单的方法,那就更好了)绘制“hieroglf”包中提供的“Cartouche”文本框形状,以便我能够将文本放入 Cartouche 中,因为由于某些原因我无法使用“hieroglf”包。

\documentclass[a4paper,12pt,twoside]{book}
\usepackage[a4paper,top=2.5cm,bottom=2.5cm,margin=2.5cm,bindingoffset=0.5cm]{geometry} 
\usepackage{pdflscape}
\usepackage[hidelinks,colorlinks=true,breaklinks,allcolors=blue]{hyperref} 

\usepackage{tikz} 
    \usetikzlibrary{tikzmark,arrows.meta,arrows,positioning,matrix,quotes, shapes.geometric,calc,decorations.pathreplacing}
\usepackage{tikz-qtree}
\usepackage[edges,linguistics]{forest}  

\usepackage[bidi=basic,layout=lists.tabular]{babel}
\babelprovide[import=ar,mapdigits,main]{arabic}
\babelprovide[import=en,language=Default]{english}

\babelfont{rm}{Latin Modern Roman}
\babelfont[arabic]{rm}{amiri}
\babelfont{hieroglyphs}{Noto Sans Egyptian Hieroglyphs}

\usepackage{booktabs}
\usepackage{makecell} 
\usepackage{boldline} 



\usepackage{fancyhdr} 
\usepackage[normalem]{ulem}


\begin{document}

\begin{figure}[!htbp]
\centering
\begin{tikzpicture}
\node [
        black,
        ultra thick,
        draw, 
        rectangle, 
        rounded corners=3ex,
        inner sep=0.25em,
        ]
        {{\textbf{\Huge\texthieroglyphs{

答案1

像这样?

\documentclass{article} 
\usepackage{tcolorbox} 
\newtcbox{\CartoucheBox}{colback=white,boxrule=0.6pt}

\begin{document} 
\CartoucheBox{A cartouche box.} 
\end{document}

在此处输入图片描述

通过几个坐标计算(使用calc库),您可以得到这个形状:

\documentclass{article} 
\usepackage[skins]{tcolorbox} 
\usetikzlibrary{calc}
\pgfkeys{/cartouche/.is family,/cartouche/.cd,frame sep/.initial=1mm,
end width/.initial=2mm,frame arc/.initial=3pt}
\newtcbox{\CartoucheBox}{colback=white,boxrule=0pt,enhanced,colframe=white,
overlay={\draw[thin] let \p1=($(frame.north east)-(frame.south west)$),
\n1={\pgfkeysvalueof{/cartouche/frame sep}},
\n2={\pgfkeysvalueof{/cartouche/end width}},
\n3={\pgfkeysvalueof{/cartouche/frame arc}},
\n4={asin((\n2/2+\n3)/(\y1/2+\n1))} in 
(frame.south west) arc[start angle=270,end angle=90,radius=\y1/2] 
-- (frame.north east) arc[start angle=90,end angle=-90,radius=\y1/2] 
-- cycle
([yshift=-\n1]frame.south west)
 arc[start angle=270,end angle=90,radius={\y1/2+\n1}]
 -- ([yshift=\n1]frame.north east)
arc[start angle=90,end angle=\n4,radius={\y1/2+\n1}]
arc[start angle=180+\n4,end angle=360,radius=\n3] coordinate(aux)
-- ([yshift=\n1-\n3]frame.north-|aux) 
arc[start angle=180,end angle=0,radius=\n3]
-- ($([yshift=-\n1+\n3]frame.south-|aux)+(2*\n3,0)$)
arc[start angle=0,end angle=-180,radius=\n3] 
let \p2=($(aux)-(frame.east)$) in
-- ([yshift=-2*\y2]aux)
arc[start angle=0,end angle=180-\n4,radius=\n3]
arc[start angle=-\n4,end angle=-90,radius={\y1/2+\n1}] -- cycle;
}}

\begin{document} 
\CartoucheBox{A cartouche box.} 
\end{document}

在此处输入图片描述

附录: 至于你的 MWE 代码,这与此无关tcolorbox,但与你使用作为主要语言的事实有关arabic,因此从右到左书写。我不知道如何解决这个问题,看看问题和答案可能会有意义类似这样的主题。这是一个我不擅长的讨论。我只能说,如果你本地切换到从左到右的语言,比如英语,那就没有问题了。出于某种原因,TiZ 似乎会自动处理这个问题。

\documentclass[a4paper,12pt,twoside]{book}
\usepackage[a4paper,top=2.5cm,bottom=2.5cm,margin=2.5cm,bindingoffset=0.5cm]{geometry} 
\usepackage{pdflscape}
\usepackage[hidelinks,colorlinks=true,breaklinks,allcolors=blue]{hyperref} 
\usepackage[skins]{tcolorbox} 
\usetikzlibrary{calc}
\pgfkeys{/cartouche/.is family,/cartouche/.cd,frame sep/.initial=1mm,
end width/.initial=2mm,frame arc/.initial=3pt}
\newtcbox{\CartoucheBox}[1][]{colback=white,boxrule=0pt,enhanced,colframe=white,
overlay={\draw[thin] let \p1=($(frame.north east)-(frame.south west)$),
\n1={\pgfkeysvalueof{/cartouche/frame sep}},
\n2={\pgfkeysvalueof{/cartouche/end width}},
\n3={\pgfkeysvalueof{/cartouche/frame arc}},
\n4={asin((\n2/2+\n3)/(\y1/2+\n1))} in 
(frame.south west) arc[start angle=270,end angle=90,radius=\y1/2] 
-- (frame.north east) arc[start angle=90,end angle=-90,radius=\y1/2] 
-- cycle
([yshift=-\n1]frame.south west)
 arc[start angle=270,end angle=90,radius={\y1/2+\n1}]
 -- ([yshift=\n1]frame.north east)
arc[start angle=90,end angle=\n4,radius={\y1/2+\n1}]
arc[start angle=180+\n4,end angle=360,radius=\n3] coordinate(aux)
-- ([yshift=\n1-\n3]frame.north-|aux) 
arc[start angle=180,end angle=0,radius=\n3]
-- ($([yshift=-\n1+\n3]frame.south-|aux)+(2*\n3,0)$)
arc[start angle=0,end angle=-180,radius=\n3] 
let \p2=($(aux)-(frame.east)$) in
-- ([yshift=-2*\y2]aux)
arc[start angle=0,end angle=180-\n4,radius=\n3]
arc[start angle=-\n4,end angle=-90,radius={\y1/2+\n1}] -- cycle;
}}

\usepackage[bidi=basic,layout=lists.tabular]{babel}
\babelprovide[import=ar,mapdigits,main]{arabic}
\babelprovide[import=en,language=Default]{english}

\babelfont{rm}{Latin Modern Roman}
\babelfont[arabic]{rm}{amiri}

\babelfont{hieroglyphs}{Noto Sans Egyptian Hieroglyphs}


\begin{document}
\CartoucheBox{ABC}

\CartoucheBox[fontupper=\Huge\bfseries]{\texthieroglyphs{

相关内容