使用 TikZ 创建扑克牌,第 2 部分

使用 TikZ 创建扑克牌,第 2 部分

这是这篇其他文章。。感谢一些人的帮助,我快完成了,这就是我现在所拥有的:

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usepackage{pifont}
\usepackage{anttor}
\usepackage[utf8]{inputenc}
\begin{document}
\pgfmathsetmacro{\cardwidth}{5}
\pgfmathsetmacro{\cardheight}{8}
\pgfmathsetmacro{\stripwidth}{0.6}
\pgfmathsetmacro{\strippadding}{0.1}
\pgfmathsetmacro{\textpadding}{0.1}
\pgfmathsetmacro{\ruleheight}{0.15}
\begin{tikzpicture}
    \draw[rounded corners=0.2cm] (0,0) rectangle (\cardwidth,\cardheight);
    \fill[lime,rounded corners=0.1cm] (\strippadding,\strippadding) rectangle (\strippadding+\stripwidth,\cardheight-\strippadding) node[rotate=90,above left,black,font=\large] {INTER ARMA \rotatebox[origin=c]{-90}{\ding{52}}};
    \node[text width=(\cardwidth-\strippadding-\stripwidth-2*\textpadding-0.3)*1cm,below right] at (\strippadding+\stripwidth+\textpadding,\cardheight-\textpadding) {
        {\Large KEEPER}\\
        \vspace{0.15cm}
        {\scriptsize Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.}\\
        \vspace{0.25cm}
        {\large Inter Arma}\\
        \tikz{\fill (0,0) rectangle (\cardwidth-\strippadding-\stripwidth-2*\textpadding-0.3,\ruleheight);}\\
        \vspace{0.2cm}
        {\scriptsize Lorem ipsum dolor sit amet, consectetur adipisicing elit.\\
Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.}
    };
\end{tikzpicture}
\end{document}

输出卡

问题在于:

  1. “Inter Arma”下面的线应该更靠近它,就像下划线一样。
  2. 如果文本有多个段落,间距会变得不好(看图片)。我该如何控制它?
  3. 我打算使用扑克牌尺寸,我应该将宽度和高度改为 6.3 和 8.8 吗?
  4. 我上一个问题的答案中对主区域宽度的计算不正确,所以我减去了 0.3。这是为什么?它看起来本来就没问题。已解决。

答案1

对于前两个问题,我有一些解决方案。第三个问题...我不明白。您不能更改纸张大小,还是您在问是否应该更改它?您可以使用geometry包更改纸张大小。

\usepackage[paperwidth=6.3cm,paperheight=8.8cm,margin=15mm]{geometry}

前两个疑问已经在这里得到解决。

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usepackage{pifont} 
\usepackage{anttor}
\usepackage[normalem]{ulem}
\usepackage[utf8]{inputenc}
\renewcommand\ULthickness{4pt}
\setlength \ULdepth{6pt}
\begin{document}
\pgfmathsetmacro{\cardwidth}{5}
\pgfmathsetmacro{\cardheight}{8}
\pgfmathsetmacro{\stripwidth}{0.6}
\pgfmathsetmacro{\strippadding}{0.1}
\pgfmathsetmacro{\textpadding}{0.1}
\pgfmathsetmacro{\ruleheight}{0.15}
\begin{tikzpicture}
    \draw[rounded corners=0.2cm] (0,0) rectangle (\cardwidth,\cardheight);
    \fill[lime,rounded corners=0.1cm] (\strippadding,\strippadding) rectangle (\strippadding+\stripwidth,\cardheight-\strippadding) node[rotate=90,above left,black,font=\large] {INTER ARMA \rotatebox[origin=c]{-90}{\ding{52}}};
    \node[text width=(\cardwidth-\strippadding-\stripwidth-2*\textpadding-0.3)*1cm,below right] at (\strippadding+\stripwidth+\textpadding,\cardheight-\textpadding) {
        {\Large KEEPER}\\
        \vspace{0.15cm}
        {\scriptsize Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\\}%<------modified here
        \vspace{0.25cm}
       { {\large \uline{Inter Arma\hfill} }}\\ % <------modified here
%         \tikz{\fill (0,0) rectangle (\cardwidth-\strippadding-\stripwidth-2*\textpadding-0.3,\ruleheight);}\\
        \vspace{0.2cm}
        {\scriptsize Lorem ipsum dolor sit amet, consectetur adipisicing elit.\\[5pt] % <------modified here
Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\\} % <------Give a line break here
 \vfill   };
\end{tikzpicture}
\end{document}

在此处输入图片描述

我使用包ulem添加了下划线。您可以通过适当更改以下值来更改下划线的粗细和深度:

\renewcommand\ULthickness{4pt}
\setlength \ULdepth{5pt}

免责声明:如果下划线不需要位于卡片的中心,则此解决方案有效。

编辑: 由于要求容纳两行下划线,因此可以使用以下内容:

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usepackage{pifont} 
\usepackage{anttor}
\usepackage[utf8]{inputenc}
\begin{document}
\pgfmathsetmacro{\cardwidth}{5}
\pgfmathsetmacro{\cardheight}{8}
\pgfmathsetmacro{\stripwidth}{0.6}
\pgfmathsetmacro{\strippadding}{0.1}
\pgfmathsetmacro{\textpadding}{0.1}
\pgfmathsetmacro{\ruleheight}{0.15}
\begin{tikzpicture}
\draw[rounded corners=0.2cm] (0,0) rectangle (\cardwidth,\cardheight);
\fill[lime,rounded corners=0.1cm] (\strippadding,\strippadding) rectangle (\strippadding+\stripwidth,\cardheight-\strippadding) node[rotate=90,above left,black,font=\large] {INTER ARMA \rotatebox[origin=c]{-90}{\ding{52}}};
\node[text width=(\cardwidth-\strippadding-\stripwidth-2*\textpadding-0.3)*1cm,below right] at (\strippadding+\stripwidth+\textpadding,\cardheight-\textpadding) {
    {\Large KEEPER}\\
    \vspace{0.15cm}
    {\scriptsize Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\\}%<------modified here
    \vspace{0.25cm}
   {{\large {Inter Arma going into two lines\hfill} }} \\[-9pt]% <------modified here
  \vrule width \textwidth height 3pt \\[-3pt] % <------modified here
%         \tikz{\fill (0,0) rectangle (\cardwidth-\strippadding-\stripwidth-2*\textpadding-0.3,\ruleheight);}\\
        \vspace{0.2cm}
        {\scriptsize Lorem ipsum dolor sit amet, consectetur adipisicing elit.\\[5pt] % 
<------modified here
Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\\} % <------Give a line break here
 \vfill   };

\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容