0

Greetings I would like to add sentence format comma, period and plus sign in the following latex code:

\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}}}}} % new command comma, plus sign and period \newcommand{\iscomma}[1]....... \newcommand{\isplusign}[1].............. \newcommand{\isperiod}[1]................ \begin{document} \isnoun{Japan} \isverb{is} a country. \isnoun{Japan} \isverb{is} a country.

\end{document}

Thank again for your help.

  • 2
    It would be helpful if you described what kind of output you are expecting... – campa Apr 22 '21 at 08:05
  • camp, thank you very much. I would like to write these to the top of sentence words. Japan is a country, = N + V + Comma or period. – user3056542 Apr 27 '21 at 13:10

1 Answers1

1

If I understand correctly, something like this where the annotated version picks up even non standard settings of the second example.

enter image description here

\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}

\definecolor{color1}{RGB}{219, 48, 122} \definecolor{color2}{RGB}{48, 122, 219} \definecolor{color3}{RGB}{200,0,0} \newcommand{\isnoun}[1]{\ensuremath{\overset{\makebox[0pt]{\scriptsize\color{color1}\textbf{N}}}{\strut\text{#1}}}} \newcommand{\isverb}[1]{\ensuremath{\overset{\makebox[0pt]{\scriptsize\color{color2}\textbf{V}}}{\strut\text{#1}}}} % new command comma, plus sign and period \newcommand{\iscomma}[1]{\ensuremath{\overset{\makebox[0pt]{\scriptsize\color{color3}\textbf{P}}}{\strut\text{#1}}}\spacefactor\sfcode`#1 } \let\isplusign\iscomma \let\isperiod\iscomma

\begin{document}

Japan is a country, France is a country. Japan is a country, France is a country. Japan is a country, France is a country. Japan is a country, France is a country.

\isnoun{Japan} \isverb{is} a country\iscomma{,} \isnoun{France} \isverb{is} a country\isperiod{.} \isnoun{Japan} \isverb{is} a country\iscomma{,} \isnoun{France} \isverb{is} a country\isperiod{.} \isnoun{Japan} \isverb{is} a country\iscomma{,} \isnoun{France} \isverb{is} a country\isperiod{.} \isnoun{Japan} \isverb{is} a country\iscomma{,} \isnoun{France} \isverb{is} a country\isperiod{.}

\bigskip % big sentence space \spaceskip=1em plus .5em minus .2em \xspaceskip=2em plus 1em minus .1em

Japan is a country, France is a country. Japan is a country, France is a country. Japan is a country, France is a country. Japan is a country, France is a country.

\isnoun{Japan} \isverb{is} a country\iscomma{,} \isnoun{France} \isverb{is} a country\isperiod{.} \isnoun{Japan} \isverb{is} a country\iscomma{,} \isnoun{France} \isverb{is} a country\isperiod{.} \isnoun{Japan} \isverb{is} a country\iscomma{,} \isnoun{France} \isverb{is} a country\isperiod{.} \isnoun{Japan} \isverb{is} a country\iscomma{,} \isnoun{France} \isverb{is} a country\isperiod{.}

\end{document}

David Carlisle
  • 757,742
  • David, thank you very much. However, I would commas, plus sign and period to be in the same line with N, V on top of line of sentence. 1: N + V . 2. N + V + N, N +V. – user3056542 Apr 27 '21 at 12:50
  • \newcommand{\iscomma}[1]{\ensuremath{\overset{\mathbf{,}}{\text{#1}}}} \newcommand{\isplussign}[1]{\ensuremath{\overset{\mathbf{+}}{\text{#1}}}} \newcommand{\isperiod}[1]{\ensuremath{\overset{\mathbf{.}}{\text{#1}}}} ``` – user3056542 Apr 27 '21 at 12:55
  • I have tried the above code, but the code does not work. commas, period and plus sign are in the same line as sentence words – user3056542 Apr 27 '21 at 12:58
  • @user3056542 you have not used the definition I gave in the answer, with \strut – David Carlisle Apr 27 '21 at 14:19
  • David, thank you again. Is it possible to use dot instead of P? and the same for comma and plus sign symbols? – user3056542 Apr 27 '21 at 22:46
  • @user3056542 did you try it ? of course yes the P is just arbitrary text you can use . or whatever you want. – David Carlisle Apr 27 '21 at 22:56
  • Yes, I have tried the code you gave in the answer. In short I am learning english grammar. so I would like to see that I can label on top of each sentences. where should I put the command \strut? – user3056542 Apr 27 '21 at 23:01
  • @user3056542 if you use the command in my answer it has \strut in the right place. – David Carlisle Apr 27 '21 at 23:05
  • David, thank you very much. it works. – user3056542 Apr 27 '21 at 23:08