我使用以下代码邮政将选定的内联文本框起来。
% Multiline Textbox
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{tikzpagenodes}
\makeatletter
\newcommand{\gettikzxy}[3]{% from https://tex.stackexchange.com/a/58590/121799
\tikz@scan@one@point\pgfutil@firstofone#1\relax
\global\edef#2{\the\pgf@x}%
\global\edef#3{\the\pgf@y}%
}
\makeatother
\newcommand{\BoxMe}[2][0.5pt]{%
\tikz[remember picture,overlay, baseline=(Begin.base)]{%
\node[anchor=base,inner sep=0pt,outer sep=0pt] (Begin) {\strut};}#2%
\tikz[remember picture,overlay, baseline=(End.base)]{%
\node[anchor=base,inner sep=0pt,outer sep=0pt] (End) {\strut};}%
\begin{tikzpicture}[overlay,remember picture]
\gettikzxy{($(Begin.north)-(current page.south west)$)}{\BeginxN}{\BeginyN}
\gettikzxy{($(End.north)-(current page.south west)$)}{\EndxN}{\EndyN}%\typeout{\BeginyN\space\EndyN}
\pgfmathtruncatemacro{\mytest}{\EndyN-\BeginyN}
\ifnum\mytest=0\relax% begin and and in the same line %\typeout{begin and end in the same line}
\draw[thick,-] ($(Begin.north)-(#1,0)$) -- ($(Begin.south)-(#1,0)$)
-- ($(End.south)+(#1,0)$) -- ($(End.north)+(#1,0)$) -- cycle;
\else% \typeout{end below begin}
\path (current page text area.north west) -- (current page text area.south west)
node(WestLine)[left]{};
\path (current page text area.north east) -- (current page text area.south east)
node(EastLine)[right]{};
\gettikzxy{($(End.north)-(current page.south west)$)}{\EndxN}{\EndyN}
\gettikzxy{($(Begin.south)-(current page.south west)$)}{\BeginxS}{\BeginyS}
\pgfmathtruncatemacro{\mytest}{\BeginyS-\EndyN+1pt}% \typeout{\mytest}
\ifnum\mytest<2\relax% \typeout{end in the next line after begin}%
\pgfmathtruncatemacro{\mytest}{\BeginxS-\EndxN}% \typeout{\mytest}
\ifnum\mytest>0\relax%
\draw[thick,-] (Begin.north -| EastLine) -- ($(Begin.north)-(#1,0)$) --
($(Begin.south)-(#1,0)$) -- (Begin.south -| EastLine);
\draw[thick,-] (End.south -| WestLine) -- ($(End.south)+(#1,0)$) --
($(End.north)+(#1,0)$) -- (End.north -| WestLine);
\else
\draw[thick,-] ($(Begin.north)-(#1,0)$) -- ($(Begin.south)-(#1,0)$) --
(Begin.south -| WestLine) -- (End.south -| WestLine)
-- ($(End.south)+(#1,0)$) -- ($(End.north)+(#1,0)$) -- (End.north -| EastLine)
-- (Begin.north -| EastLine) -- cycle;
\fi
\else
\draw[thick,-] ($(Begin.north)-(#1,0)$) -- ($(Begin.south)-(#1,0)$) --
(Begin.south -| WestLine) -- (End.south -| WestLine)
-- ($(End.south)+(#1,0)$) -- ($(End.north)+(#1,0)$) -- (End.north -| EastLine)
-- (Begin.north -| EastLine) -- cycle;
\fi
\fi
\end{tikzpicture}}
被装箱的 Unicode 字符无法正确显示。
示例文档:
% Created 2021-03-24 Wed 03:05
% Intended LaTeX compiler: xelatex
\documentclass[12pt,a4paper]{article}
%\documentclass[12pt,a4paper]{ctexart}
\usepackage{xeCJK}
\usepackage{zhnumber} % package for Chinese formatting of date time (use /zhtoday)
\usepackage[yyyymmdd]{datetime} % set date time to numeric
% For Generation of Citations and Bibliography
\usepackage[notes, isbn=false, backend=biber]{biblatex-chicago}
\bibliography{/Users/satibodhi/Creation/notes/bibliography/thesis}
% Dummy Text for Testing
\usepackage{lipsum}
\usepackage{zhlipsum}
% Multiline Textbox
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{tikzpagenodes}
\makeatletter
\newcommand{\gettikzxy}[3]{% from https://tex.stackexchange.com/a/58590/121799
\tikz@scan@one@point\pgfutil@firstofone#1\relax
\global\edef#2{\the\pgf@x}%
\global\edef#3{\the\pgf@y}%
}
\makeatother
\newcommand{\BoxMe}[2][0.5pt]{%
\tikz[remember picture,overlay, baseline=(Begin.base)]{%
\node[anchor=base,inner sep=0pt,outer sep=0pt] (Begin) {\strut};}#2%
\tikz[remember picture,overlay, baseline=(End.base)]{%
\node[anchor=base,inner sep=0pt,outer sep=0pt] (End) {\strut};}%
\begin{tikzpicture}[overlay,remember picture]
\gettikzxy{($(Begin.north)-(current page.south west)$)}{\BeginxN}{\BeginyN}
\gettikzxy{($(End.north)-(current page.south west)$)}{\EndxN}{\EndyN}%\typeout{\BeginyN\space\EndyN}
\pgfmathtruncatemacro{\mytest}{\EndyN-\BeginyN}
\ifnum\mytest=0\relax% begin and and in the same line %\typeout{begin and end in the same line}
\draw[thick,-] ($(Begin.north)-(#1,0)$) -- ($(Begin.south)-(#1,0)$)
-- ($(End.south)+(#1,0)$) -- ($(End.north)+(#1,0)$) -- cycle;
\else% \typeout{end below begin}
\path (current page text area.north west) -- (current page text area.south west)
node(WestLine)[left]{};
\path (current page text area.north east) -- (current page text area.south east)
node(EastLine)[right]{};
\gettikzxy{($(End.north)-(current page.south west)$)}{\EndxN}{\EndyN}
\gettikzxy{($(Begin.south)-(current page.south west)$)}{\BeginxS}{\BeginyS}
\pgfmathtruncatemacro{\mytest}{\BeginyS-\EndyN+1pt}% \typeout{\mytest}
\ifnum\mytest<2\relax% \typeout{end in the next line after begin}%
\pgfmathtruncatemacro{\mytest}{\BeginxS-\EndxN}% \typeout{\mytest}
\ifnum\mytest>0\relax%
\draw[thick,-] (Begin.north -| EastLine) -- ($(Begin.north)-(#1,0)$) --
($(Begin.south)-(#1,0)$) -- (Begin.south -| EastLine);
\draw[thick,-] (End.south -| WestLine) -- ($(End.south)+(#1,0)$) --
($(End.north)+(#1,0)$) -- (End.north -| WestLine);
\else
\draw[thick,-] ($(Begin.north)-(#1,0)$) -- ($(Begin.south)-(#1,0)$) --
(Begin.south -| WestLine) -- (End.south -| WestLine)
-- ($(End.south)+(#1,0)$) -- ($(End.north)+(#1,0)$) -- (End.north -| EastLine)
-- (Begin.north -| EastLine) -- cycle;
\fi
\else
\draw[thick,-] ($(Begin.north)-(#1,0)$) -- ($(Begin.south)-(#1,0)$) --
(Begin.south -| WestLine) -- (End.south -| WestLine)
-- ($(End.south)+(#1,0)$) -- ($(End.north)+(#1,0)$) -- (End.north -| EastLine)
-- (Begin.north -| EastLine) -- cycle;
\fi
\fi
\end{tikzpicture}}
% Set default indentation
\setlength\parindent{24pt}
% Set Paper Size, Page Layout (another variable is 'bindingoffset')
\usepackage[margin = 1.5in, paper = a4paper, inner = 2.5cm,
outer = 2.5cm, top = 3cm, bottom = 2.5cm]{geometry}
% Keep paragraph indentation while having a line break in between paragraphs.
\edef\restoreparindent{\parindent=\the\parindent\relax}
\usepackage{parskip}
\restoreparindent
% Indent first paragraph.
\usepackage{indentfirst}
\usepackage{titlesec}
\usepackage{titling}
\usepackage{fontspec} % packages for title and section-heading font setting.
\usepackage{newunicodechar} % custom fallback font for certain unicode characters.
\usepackage{tocloft} % adding the tocloft package for toc customization
\usepackage{titletoc} % custom toc indentation and label width.
% Set Header and Numbering Depth
\setcounter{tocdepth}{5}
\setcounter{secnumdepth}{5}
% Set Font.
\setsansfont{Calibri}
\setmainfont{Times New Roman} % Set serifed font to Calibri. Originally set to 'Times New Roman', but it cannot display certain characters such as ①②③.
\setCJKmainfont{Songti TC}
\setCJKsansfont{Kaiti TC} % Set Chinese font. NOTE: Remember to append CJK before of the font class. CJK HAS to be there for the font to show.
\setCJKmonofont{PingFang TC}
% Set fallback fonts for ㊀ characters.
\newunicodechar{㊀}{{\ttfamily ㊀}}
\newunicodechar{㊁}{{\ttfamily ㊁}}
\newunicodechar{㊂}{{\ttfamily ㊂}}
\newunicodechar{㊃}{{\ttfamily ㊃}}
\newunicodechar{㊄}{{\ttfamily ㊄}}
\newunicodechar{㊅}{{\ttfamily ㊅}}
\newunicodechar{㊆}{{\ttfamily ㊆}}
\newunicodechar{㊇}{{\ttfamily ㊇}}
\newunicodechar{㊈}{{\ttfamily ㊈}}
\newunicodechar{㊉}{{\ttfamily ㊉}}
\newunicodechar{・}{{\ttfamily ・}}
\newCJKfontfamily\rarechar{HanaMinB}
\newunicodechar{