tikzpicture で \textwidth を使用して中央揃えの画像を作成する

tikzpicture で \textwidth を使用して中央揃えの画像を作成する

tikzpicture を横向きで A4 ページの中央に配置したいのですが、\textwidthおよびコマンドは使用できません。またはエラー\textheightが発生し、最初のページが空白になります。 どこかに何らかの小さな余白またはインデントがあると思いますか?overfull \hbox...overfull \vbox...

私はカップルスレッドここにいますが、今のところ何も機能していません。MWE:

\documentclass[a4paper,landscape]{minimal}

\usepackage[margin=1cm]{geometry}
\usepackage{tikz}

\begin{document}
\begin{center}
\begin{tikzpicture}
  \draw (0, 0) rectangle (0.999\textwidth,0.999\textheight);

  % this will give "overfull \hbox..." or "overfull \vbox..." errors
  % and create an empty first page
  % \draw (0, 0) rectangle (\textwidth,\textheight);
\end{tikzpicture}
\end{center}
\end{document}

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

ありがとう!

答え1

ようこそ!線の幅を考慮する必要があります。(fractal の提案に従って、記事に切り替えました。)各端では、境界ボックスが ずつ増加するため、\pgflinewidth/2それを修正する必要があります。

\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{tikz}

\begin{document}
%\begin{center} %<- not needed
\noindent\begin{tikzpicture}
  \draw (0, 0) rectangle (\textwidth-\pgflinewidth,\textheight-\pgflinewidth);
\end{tikzpicture}
%\end{center}
\end{document}

関連情報