Estou fazendo algumas divisões de seção em uma folha de estilos usando tikz
. No entanto, mesmo que eu comece a desenhar a linha, (0,0)
ela tem um deslocamento em relação à borda real do conteúdo da página. Eu também configurei \parindent
e ainda não está perfeitamente alinhado. Como posso forçar a linha a começar (e terminar) exatamente nas bordas?
Aqui está um exemplo mínimo do problema:
\documentclass{article}
\usepackage[a4paper, left=14.111mm,right=14.111mm,top=14.111mm,bottom=14.111mm, showframe]{geometry}
\usepackage{tikz}
\newcommand{\linehalfhalf}{\begin{tikzpicture}[]%
\draw [line width=1.5mm ] (0,0) -- ({0.5\textwidth},0);
\draw [line width=0.5mm] ([yshift=+0.5mm]{0.5\textwidth},0) -- ([yshift=+0.5mm]{\textwidth},0) ;
\end{tikzpicture}}
\begin{document}
\setlength\parindent{0pt}
\linehalfhalf
\end{document}
Responder1
Eu descobri graças a @JouleV apontando esta questão:Uma linha de comprimento \textwidth em TikZ.
O seguinte resolve o problema:
\newcommand{\linehalfhalf}{\begin{tikzpicture}[]%
\draw [line width=1.5mm, cap=rect] (0,0) -- ({0.5\linewidth},0);
\draw [line width=0.5mm, cap=rect] ([yshift=+0.5mm]{0.5\linewidth-\pgflinewidth},0) -- ([yshift=+0.5mm] \linewidth-0.5mm-\pgflinewidth,0) ;
\end{tikzpicture}}
Responder2
Uma solução é usar \clip
para evitar espaço extra ao redor do seu desenho, mas acho que uma solução mais simples é preencher um retângulo fino no lugar para desenhar uma linha:
\documentclass{article}
\usepackage[a4paper, margin=14.111mm, paper height=5cm,showframe]{geometry}
\usepackage{tikz}
\newcommand{\linehalfhalf}{\begin{tikzpicture}[]%
\fill (0,0) rectangle (.5\textwidth,1.5mm);
\fill (0.5\textwidth,.5mm) rectangle (\textwidth,1mm) ;
\end{tikzpicture}}
\begin{document}%
\setlength\parindent{0pt}%
\linehalfhalf
\end{document}