Sedスクリプトは、特定の場所でのみ間違った場所に挿入および追加されます。

Sedスクリプトは、特定の場所でのみ間違った場所に挿入および追加されます。

マニュアルページをtexに変換しようとしていますが、エラーが発生し続けます。

\item[

ファイルの先頭に

] \hfill \\

ENV(1L)と書かれたマニュアルページ部分の後ろにあります。他のすべてはうまくいくようです。

これは私のtex.sedです。

/^\<[A-Z]*[A-Z]/i \
\\item[

/^\<[A-Z]*[A-Z]/a \
] \\hfill \\\\

1i\
\\documentstyle[11pt]{article} \
\\begin{document}


1i\
\\begin{center} {\\bf 

1a\
\} \\end{center}


2i\
\\begin{description}

$a\
\\end{description}

$a\
\\end{document}


s/\\/\\verb\+\\\+/g
s/%/\\%/g
s/\^/\\\^/g
s/--/-\\hspace\{.01cm\}-/g

s/^+/ \\\\/
s/^-/ \\\\/

これはenv.asciiです:

ENV(1L)


NAME
      env - run a program in a modified environment

SYNOPSIS
      env    [-]    [-i]    [-u   name]   [--ignore-environment]
      [--unset=name] [name=value]... [command [args...]]

DESCRIPTION
      This manual page documents the GNU version  of  env.   env
      runs  a  command with an environment modified as specified
      by the command line  arguments.   Arguments  of  the  form
      `variable=value'  set the environment variablevariable to
      valuevalue.  value may be empty (`variable=').  Setting a
      variable to an empty value is different from unsetting it.

      The  first  remaining  argument  specifies  a  program  to
      invoke;  it is searched for according to the specification
      of the PATH environment variable.  Any arguments following
      that are passed as arguments to that program.

      If  no command name is specified following the environment
      specifications,  the  resulting  environment  is  printed.
      This is like specifying a command name of `printenv'.

OPTIONS
     -u, --unset name
             Remove  variable name  from the environment, if it
             was in the environment.

     -, -i, --ignore-environment
             Start  with  an  empty  environment,  ignoring  the
             inherited environment.

      The  long-named options can be introduced with `+' as well
      as `--', for compatibility with previous releases.   
      Eventually  support  for  `+'  will  be removed, because it 
      is incompatible with the POSIX.2 standard.

これが私がコンパイルする方法です:

sed -f tex.sed env.ascii > env.tex

私のenv.texは次のようになります。

\documentstyle[11pt]{article} 
\begin{document}
\begin{center} {\bf 
\item[
ENV(1L)
] \hfill \\
} \end{center}
\begin{description}


\item[
NAME
] \hfill \\
      env - run a program in a modified environment

\item[
SYNOPSIS
] \hfill \\
      env    [-]    [-i]    [-u   name]   [-\hspace{.01cm}-ignore-environment]
      [-\hspace{.01cm}-unset=name] [name=value]... [command [args...]]

\item[
DESCRIPTION
] \hfill \\
      This manual page documents the GNU version  of  env.   env
      runs  a  command with an environment modified as specified
      by the command line  arguments.   Arguments  of  the  form
      `variable=value'  set the environment variablevariable to
      valuevalue.  value may be empty (`variable=').  Setting a
      variable to an empty value is different from unsetting it.

      The  first  remaining  argument  specifies  a  program  to
      invoke;  it is searched for according to the specification
      of the PATH environment variable.  Any arguments following
      that are passed as arguments to that program.

      If  no command name is specified following the environment
      specifications,  the  resulting  environment  is  printed.
      This is like specifying a command name of `printenv'.

\item[
OPTIONS
] \hfill \\
     -u, --unset name
             Remove  variable name  from the environment, if it
             was in the environment.

     -, -i, --ignore-environment
             Start  with  an  empty  environment,  ignoring  the
             inherited environment.

      The  long-named options can be introduced with `+' as well
      as `-\hspace{.01cm}-', for compatibility with previous releases.   
      Eventually  support  for  `+'  will  be removed, because it 
      is incompatible with the POSIX.2 standard.
\end{description}
\end{document}

ノート

最終結果は、sedマニュアルページをファイルに正しく変換するスクリプトでなければなりません.tex。問題を解決するための他の方法を提案しないでください。

ベストアンサー1

あなたが望むものがPDF形式のマニュアルページだけなら、manそれ自体でそれを行うことができます。このツールバーが必要で、PDF形式でページをghostscriptインポートするなどの操作を実行できます。bash(1)

man -T ps bash|ps2pdf - bash.pdf

ghostscriptLaTeXを使用してDVIのマニュアルページを作成したい場合は、これを直接man行う必要はありません。

man -T dvi bash >bash.dvi

Bichoyのコメントをそのまま引用

-T ps オプションは人に移植可能ではありません。 RHEL6 では、正しい構文は man -t bash です。 -t オプションは /usr/bin/groff -Tps -mandoc を使用して出力を ps に設定します。

sedスクリプトに関するいくつかの注意

  • 私に効果があったのは、スクリプトの最初の6行を\\begin{center}この行の後ろに移動することでした。一度試して、これが望ましい結果であることを確認してください。
  • マニュアルページの内容から特殊文字をエスケープするには、かなりの努力が必要です。あなたのスクリプトは現在これらのいくつかをエスケープしますが、常に1つを忘れる可能性があります。少なくとも&(La)TeXが列の区切り記号として使用するアンパサンド()をエスケープするのを忘れてしまったと言えます。これがUmläuteと私がTeXifyへの代替アプローチを直接提案してきた理由です。
  • 文書の冒頭にタイプミスがありますか?それとも実際にはその\\documentstyle逆でなければなりませんか\\documentclass
  • タグで囲まれたコマンド名を除外するには、\item大文字のみの単語に一致するように正規表現を変更する必要があり\<[A-Z]*[A-Z]ます^\s*[A-Z][A-Z]*\s*$

おすすめ記事