中央揃えのカラーボックスを作成する方法

中央揃えのカラーボックスを作成する方法

私は中央に色付きのパーボックスしかし、私はパッケージを使用して境界を定義しましたが幾何学、パーボックスは右よりも左の余裕が大きくなります。

手伝ってくれてありがとう

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{color}
\usepackage[a4paper,top=1cm,left=2cm,right=2cm]{geometry}
\usepackage{graphicx}


\begin{document}

\definecolor{Blau1}{RGB}{0,97,175}
\definecolor{Blau2}{RGB}{86,189,218}
\definecolor{Blau3}{RGB}{212,239,252} % Define a custom color for the heading box

\colorbox{Blau3}{ % Creates a highlight behind the text using the previously-defined navy color

\parbox[t]{\linewidth}{ % Creates a box to take up the entire line width
\centering

\vspace*{14pt} % Whitespace above the text

\color{Blau1} \center{\textbf{\Large REPORT}} % Right-aligned heading text

\vspace*{14pt} % Whitespace below the text
}}


\end{document}

答え1

カラーボックスの前のインデントとボックスの自然なパディング(別の呼び方があるかもしれませんが、よくわかりません)を削除する必要があります。後者については、パッケージを使用しcalc、parbox の長さを に設定して\textwidth-2\fboxseptextwidth自然なパディングを差し引きました。

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{color}
\usepackage[a4paper,top=1cm,left=2cm,right=2cm]{geometry}
\usepackage{graphicx}
\usepackage{showframe}
\usepackage{calc}

\begin{document}

\definecolor{Blau1}{RGB}{0,97,175}
\definecolor{Blau2}{RGB}{86,189,218}
\definecolor{Blau3}{RGB}{212,239,252} 
\noindent\colorbox{Blau3}{% new code here
\parbox[t]{\textwidth-2\fboxsep}{% new code here
\centering
\vspace*{14pt} 
\color{Blau1} \center{\textbf{\Large REPORT}}
\vspace*{14pt}
}}
\end{document}

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

関連情報