画像が正しく中央に配置されないのはなぜですか?



Why Are My Images Not Correctly Centered



解決:

秘訣は、グラフィックを vCenterボックス。残りはただの官僚主義です: vCenterには数学モードが必要であり、 hboxは、画像が線幅全体を占めるのを防ぎます。

 documentclass {article}  usepackage {graphics}  newcommand  myincludegraphics [1] {% ensuremath { vcenter { hbox { includegraphics {#1}}}}%}  begin {document}  begin {figure} センタリング renewcommand  arraystretch {3}  begin {tabular} {rcl} description& myincludegraphics {gfx / test}&description \ description& myincludegraphics {gfx / test}&description \ description& myincludegraphics {gfx / test}&description \ description&  myincludegraphics {gfx / test}&description \&0  hfill 5  hfill  hfill 15  hfill  hfill  hfill 30&min  end {tabular}  caption {A caption}  label {fig:figure}  end {figure}  end {document}

編集:このバージョンは、さまざまな長さの説明を扱い、何があっても画像を水平方向の中央に保ちます。



主なアイデアは、左側の説明を llap(ふりをしながら、左に突き出るようにします0pt幅)と正しい説明 hbox to 0pt(これらはふりをします幅0ptですが、右に突き出ています---ちなみに、この場合、 rlapはうまく機能しません)。

残りは物事を使いやすくすることです。パッケージ配列を使用すると、エントリの周囲に自動的に任意のコードを使用できます。< and >。さらに、新しい列タイプを定義できます。だから私はすべてを置きました llapと列タイプの hboxマジックC、そしてそこにも垂直測位魔法が含まれていました。これにより、使いやすくなります。



中央の列タイプが再定義されたため、古いタイムラインが機能しなくなったため、 multicolumnは、最後の行の中央の列タイプを単純なものにリセットしますNS。その間、さらに入力する手間を省くために、すべてをマクロにパックしました。 (たぶん、LaTeXにタイムライン上の数字を自動的に配置させることで、非常に凝ったものにする必要がありますか?:-))))

 documentclass {article}  usepackage {graphicx}  usepackage {array}  newcolumntype {C} {%> { llap  bgroup} c {$  vCenter  bgroup  hbox  bgroup} c { hbox to 0pt  bgroup} NS<{egroup}% }% 
ewcommand	imeline[1]{&multicolumn{1}{c}{#1}&min} egin{document} egin{figure} centering 
enewcommandarraystretch{3} egin{tabular}{C} description long&includegraphics{gfx/test}&desc\ description&includegraphics{gfx/test}&description very very extremely long\ description&includegraphics{gfx/test}&desc\ description&includegraphics{gfx/test}&descript\ 	imeline{0hfill 5hfillhfill 15hfillhfillhfill 30} end{tabular} caption{A caption} label{fig:figure1} end{figure} egin{figure} centering 
enewcommandarraystretch{3} egin{tabular}{C} description long&includegraphics{gfx/test}&desc\ description very very extremely long&includegraphics{gfx/test}&desc\ description&includegraphics{gfx/test}&desc\ description&includegraphics{gfx/test}&descript\ 	imeline{% makebox[0pt][c]{0}hfill makebox[0pt][c]{5}hfillhfill makebox[0pt][c]{15}hfillhfillhfill makebox[0pt][c]{30}} end{tabular} caption{A caption} label{fig:figure2} end{figure} end{document}  

更新2:自動ティック配置(楽しみのため)と固定列間間隔(実際のため):

 documentclass {article}  usepackage {graphicx}  usepackage {array}  newcolumntype {C} {%> { llap  bgroup} c {$  vCenter  bgroup  hbox  bgroup} c { hskip 1em  hbox to 0pt  bgroup} c<{egroup}% }% usepackage{etoolbox} 
ewcommand	imeline[1]{% &multicolumn{1}{@{} [email protected] {}}egingroup globalletdofirstT docsvlist{#1}% endgroup&min% } deffirstT#1{makebox[0pt][c]{#1}xdefpreviousT{#1}globalletdootherTs} defotherTs#1{% count0=#1
elax advancecount0-previousT
elax loopifnumcount0>0  typeout { the  count0}  Advance  count0-1  hfill  repeat  makebox [0pt] [c] {#1}  xdef  previousT {#1}%}  begin {document}  begin {figure }  centering  renewcommand  arraystretch {3}  begin {tabular} {C} description long& includegraphics {gfx / test}&desc \ description& includegraphics {gfx / test}&description very very very long \ description& includegraphics {gfx / test}&desc \ description& includegraphics {gfx / test}&descript \  timeline {0,5,15,30} \  timeline {0,10,20,30} \  timeline {0,20、 25,30} \  end {tabular}  caption {Aキャプション}  label {fig:figure1}  end {figure}  begin {figure}  centering  renewcommand  arraystretch {3}  begin {tabular} {C } description long& includegraphics {gfx / test}&desc \ description very very very long& includegraphics {gfx / test}&description \ description& includegraphics {gfx / test}&desc \ description& includegraphics {gfx / test}&descript \  timeline {0,2,4,6,8,10,20,30}  end {tabular}  caption {キャプション}  label {fig:figure1}  end {figure}  end {document}

更新:左揃えの左の説明



左端の最も広い説明の幅を事前に知っておく必要があるため、これを自動的に行う方法がわかりません。半自動の解決策は、この長さを事前に設定することです。表形式の環境---列の定義は、左側の説明を指定された幅の hbox。

 documentclass {article}  usepackage {graphicx}  usepackage {array}  newlength  widestLeftEntryLength  newcolumntype {C} {%> { llap  bgroup  hbox to  widestLeftEntryLength  bgroup} c {$  vcenter  bgroup  hbox  bgroup} c { hskip 1em  hbox to 0pt  bgroup} c<{egroup}% }% egin{document} egin{figure} centering 
enewcommandarraystretch{3} settowidthwidestLeftEntryLength{description very very extremely long} egin{tabular}{C} description long&includegraphics{gfx/test}&desc\ description very very extremely long&includegraphics{gfx/test}&description\ description&includegraphics{gfx/test}&desc\ description&includegraphics{gfx/test}&descript\ end{tabular} caption{A caption} label{fig:figure2} end{figure} end{document}   

比較のために、これはConTeXtで同様のテーブルをタイプセットする方法です。水平方向に最初の列は右にフラッシュされ、2番目の列は中央に配置され、3番目の列は左にフラッシュされます。垂直方向では、すべての列が中央揃えになっています(lohiキーワード)。

 useMPlibrary [dum]%ダミーフィギュアの場合 startsetups table:align  setupTABLE [frame = off]  setupTABLE [column] [1] [align = {flushright、lohi}]  setupTABLE [column] [2] [align = { middle、lohi}]  setupTABLE [column] [3] [align = {flushleft、lohi}]  stopsetups  starttext  startTABLE [setups = {table:align}]  NC long desc  NC  externalfigure [dummy] [width = 3cm、height = 3  lineheight]  NC desc  NC  NR  NC desc  NC  externalfigure [dummy] [width = 3cm、height = 3  lineheight]  NC desc  NC  NR  NC desc  NC  externalfigure [dummy] [width = 3cm、height = 3  lineheight]  NC desc  NC  NR  NC desc  NC  externalfigure [dummy] [width = 3cm、height = 3  lineheight]  NC long desc  NC  NR  stopTABLE  stoptext

これは

ここに画像の説明を入力してください

セル間のデフォルトの距離は、オフセットキー。

編集 :最初の列のテキストをフラッシュしたままにする場合は、の最初の行を変更するだけです。startsetupsとして:

 startsetups table:align  setupTABLE [frame = off]  setupTABLE [column] [5] [align = {flushleft、lohi}]  setupTABLE [column] [6] [align = {middle、lohi}]  setupTABLE [column ] [7] [align = {flushleft、lohi}]  stopsetups

これは

ここに画像の説明を入力してください

長い行がある場合は、中央の列が必要なだけのスペースを取るように指定できます(width = fit)、1列目と2列目は、残りのスペースをそれらの間で均等に分割します(width = wide)。例えば:

 startsetups table:align  setupTABLE [frame = off]  setupTABLE [column] [9] [align = {flushright、lohi}、width = Broad]  setupTABLE [column] [10] [align = {middle、lohi}、 width = fit、]  setupTABLE [column] [11] [align = {flushleft、lohi}、width = Broad]  stopsetups

与える(私はを使用してページフレームを示しましたテーブルがページの視覚的に中央に配置されていることが明確になるように showframe)

ここに画像の説明を入力してください

デフォルトでは、ConTeXtは最初のセルの両方の行を同じ長さにしようとしていることに注意してください。それが気に入らない場合は、追加できますのセットへの幅広いキーワードキーを揃えると、ConTeXtは各行を可能な限り長くします。例えば、

 startsetups table:align  setupTABLE [frame = off]  setupTABLE [column] [13] [align = {flushright、broad、lohi}、width = Broad]  setupTABLE [column] [14] [align = {middle、lohi }、width = fit、]  setupTABLE [column] [15] [align = {flushleft、lohi}、width = Broad]  stopsetups

与える

ここに画像の説明を入力してください