问题描述
任何人都可以帮忙。 如何在 LaTeX 的句子中标记英语语法符号? 例如。
- 日本是国家。 日本这个词上面的标签是名词,IS是动词
感谢您的帮助。
解决方法
尽管它们适用于文本模式,但我发现许多使用数学模式语法“作弊”的解决方案。所以这是我的“作弊”草图。我定义了两个 newcommand
以根据需要多次使用:
\documentclass{article}
\usepackage{amsmath}
\newcommand{\isnoun}[1]{\ensuremath{\overset{\mathbf{N}}{\text{#1}}}}
\newcommand{\isverb}[1]{\ensuremath{\overset{\mathbf{V}}{\text{#1}}}}
\begin{document}
\isnoun{Japan} \isverb{is} a country.
\isnoun{Japan} \isverb{is} a country.
\isnoun{Japan} \isverb{is} a country.
\isnoun{Japan} \isverb{is} a country.
\isnoun{Japan} \isverb{is} a country.
\isnoun{Japan} \isverb{is} a country.
\isnoun{Japan} \isverb{is} a country.
\isnoun{Japan} \isverb{is} a country.
\end{document}
记住标题中的 \usepackage{amsmath}
。输出如下:
要为标签或文本添加颜色,您可以执行以下操作:
\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\definecolor{color1}{RGB}{219,48,122}
\definecolor{color2}{RGB}{48,122,219}
\newcommand{\isnoun}[1]{\ensuremath{\overset{{\color{color1}\mathbf{N}}}{\text{#1}}}}
\newcommand{\isverb}[1]{\ensuremath{\overset{\mathbf{V}}{{\color{color2}\text{#1}}}}}
\begin{document}
\isnoun{Japan} \isverb{is} a country.
\isnoun{Japan} \isverb{is} a country.
\isnoun{Japan} \isverb{is} a country.
\isnoun{Japan} \isverb{is} a country.
\isnoun{Japan} \isverb{is} a country.
\isnoun{Japan} \isverb{is} a country.
\isnoun{Japan} \isverb{is} a country.
\isnoun{Japan} \isverb{is} a country.
\end{document}