
フォーマットのユースケース用にいくつかの環境を作成しました。何らかの理由で、 で奇妙な配置の問題が発生していますlongtable
。そこに目に見えないプレースホルダーがあり、それがすべてを台無しにしていると思いますが、数時間経ち、不要なスペースをすべて削除した後でも、それを見つけることができません。
私の環境は次のとおりです:
\newenvironment{ucflowofevents}{%
\newcommand{\event}[1]{\item{##1}}%
\begin{enumerate}
}{%
\end{enumerate}
}
\newenvironment{ucentryconditions}{%
\newcommand{\cond}[1]{\item{##1}}%
\begin{itemize}
}{%
\end{itemize}
}
\newenvironment{ucexitconditions}{%
\newcommand{\cond}[1]{\item{##1}}%
\begin{itemize}
}{%
\end{itemize}
}
\newenvironment{ucrequirements}{%
\newcommand{\req}[1]{\item{##1}}%
\begin{itemize}
}{%
\end{itemize}
}
\newenvironment{pcusecase}[1]{%
\newcommand{\row}[3][\hline]{##2 & ##3 \\ ##1}
\newcolumntype{L}{>{\vspace{-1.0\baselineskip}\flushleft\arraybackslash}p{4cm}}%
\newcolumntype{R}{>{\vspace{-1.0\baselineskip}\raggedright\arraybackslash}b{10cm}}%
\newcommand{\giveninitactors}{REQUIRED!!!}%
\newcommand{\givenevents}{REQUIRED!!!}%
\newcommand{\givencommswith}{}%
\newcommand{\givenentries}{}%
\newcommand{\givenexits}{}%
\newcommand{\givenreqs}{}%
\newcommand{\initactors}[1]{\gdef\giveninitactors{##1}}%
\newcommand{\commswith}[1]{\gdef\givencommswith{##1}}%
\newcommand{\events}[1]{\gdef\givenevents{\begin{ucflowofevents}##1\end{ucflowofevents}}}%
\newcommand{\entries}[1]{\gdef\givenentries{\begin{ucentryconditions}##1\end{ucentryconditions}}}%
\newcommand{\exits}[1]{\gdef\givenexits{\begin{ucexitconditions}##1\end{ucexitconditions}}}%
\newcommand{\reqs}[1]{\gdef\givenreqs{\begin{ucrequirements}##1\end{ucrequirements}}}%
\let\givencommswith\empty%
\let\givenentries\empty%
\let\givenexits\empty%
\let\givenreqs\empty%
\centering%
\begin{longtable}{|LR|}\hline %
\row{Use Case:}{#1}
}{%
\row{Initiating Actors:}{\giveninitactors}%
\ifx\givencommswith\empty\else \row[]{Communicates With:}{\givencommswith} \fi %\hline %
\hline\row{Flow of Events:}{\givenevents} %
\ifx\empty\givenentries\else \row{Entry Conditions:}{\givenentries} \fi %
\ifx\empty\givenexits\else \row{Exit Conditions:}{\givenexits} \fi %
\ifx\empty\givenreqs\else \row{Quality Requirements:}{\givenreqs} \fi%
\end{longtable}%
}
最初の 4 つは、イベントのフロー、開始条件と終了条件、および品質要件のリストを設定するだけです。ただし、pcusecase
を設定しますlongtable
。
定義に注意してください\newcolumntype
:
\newcolumntype{L}{>{\vspace{-1.0\baselineskip}\flushleft\arraybackslash}p{4cm}}%
\newcolumntype{R}{>{\vspace{-1.0\baselineskip}\raggedright\arraybackslash}b{10cm}}%
私が本当に望んでいるのは、両方を上揃えにすることですが、b
右側 (R) の列を指定すると、結果が誇張されてしまうため、右側 (R) の列を指定しました。これが私の使用例です。
\begin{pcusecase}{TestUseCase}%
\initactors{Rider, Admin}%
\commswith{GPSService}%
\events{\item{Event 1}%
\item{Event 2}}%
\entries{\cond{Entry Condition 1}%
\cond{Entry Condition 2}}%
\exits{\cond{Exit Condition 1}%
\cond{Exit Condition 1}}%
\reqs{\req{Requirement 1}%
\req{Requirement 2}
\req{Requirement 3}}%
\end{pcusecase}
出力は次のようになります:
最初の 3 行では、右側のセルが下揃えになっていますが、残りの行では、左側のセルが下揃え、右側のセルが上揃えになっていることに注意してください。
左を下揃え、右を上揃えにするように指定すると、
\newcolumntype{L}{>{\vspace{-1.0\baselineskip}\flushleft\arraybackslash}b{4cm}}%
\newcolumntype{R}{>{\vspace{-1.0\baselineskip}\raggedright\arraybackslash}p{10cm}}%
私はこれを理解します:
左はどういうわけか上揃え、右は下揃えになっています。最も奇妙で、おそらく誰かにヒントを与えるのは、両方を下揃えにするように指定したときに次のようになることです。
3 つのバージョンすべてにおいて、左上の 3 つのセルの配置は変わりませんでした。何時間も見つめていました。この件については、新たな視点が必要です。ご協力をいただければ幸いです...
答え1
標準の垂直配置オプションがどのように機能するかのデモンストレーションを次に示します。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\newcommand\demobox[1]{%
\fbox{%
\begin{minipage}[#1]{.25\textwidth}
\tikz[baseline=(n.base)]{%
\node (n) [inner sep=0pt, outer sep=0pt, text width=\linewidth] {Top};
\draw [red] (n.west |- n.base) -- (n.east |- n.base);}
\par
This is a box with some content which should be longer than can be accommodated on one line.
\par
\tikz[baseline=(n.base)]{%
\node (n) [inner sep=0pt, outer sep=0pt, anchor=base, text width=\linewidth] {Bottom};
\draw [red] (n.west |- n.base) -- (n.east |- n.base);}
\end{minipage}}}
\demobox{t}
\demobox{b}
\demobox{c}
\end{document}
赤い線は、各 の最初の行と最後の行のベースラインを示していますminipage
。最初の行は に揃えられ、2 番目のt
行は に揃えられているためb
、最初の の最初の行のベースラインと 2 番目の の最後の行のベースラインは揃えられています。( はc
比較のためだけのものです。)
通常のテキスト行のベースラインに合わせて配置した場合も同じことが起こります。
This is a line of regular text across the page. Here we go\dots\par
and some text \demobox{t}
and some more \demobox{b}\par
もう 1 つの複雑な点は、enumerate
環境によって、最初の項目の前と最後の項目の後に垂直方向のスペースがデフォルトで含まれることです。
\documentclass{article}
\begin{document}
\fbox{%
\parbox[t]{.25\textwidth}{%
\begin{enumerate}
\item Item
\item Item
\item Item
\end{enumerate}}} and here is the line of text.
\fbox{%
\parbox[t]{.25\textwidth}{%
Top line of text.\par Next line.\par Bottom line.}}
\fbox{%
\parbox[b]{.25\textwidth}{%
\begin{enumerate}
\item Item
\item Item
\item Item
\end{enumerate}}} and here is the line of text.
\fbox{%
\parbox[b]{.25\textwidth}{%
Top line of text.\par Next line.\par Bottom line.}}
\end{document}