나중에 플래시카드로 다시 인쇄할 수 있는 인라인 질문 만들기

나중에 플래시카드로 다시 인쇄할 수 있는 인라인 질문 만들기

저는 tufte-book 문서 클래스의 유인물을 작업 중이지만 텍스트 내에서 동일한 형식(학습할 것으로 예상되는 내용을 표시하기 위해 앞면과 뒷면을 나란히 표시)으로 인쇄되는 플래시카드를 인라인으로 만들고 싶었습니다. 부록에 적절한 플래시카드가 있습니다. flacards와 결합하면 완벽해 보이는 문서 클래스를 찾았습니다 scontents.

문제는 하나의 문서에서 두 개의 문서 클래스를 사용할 수 없고, 내용이 scontents. 누구든지 더 나은 접근 방식을 찾도록 도와줄 수 있습니까?

그래서 저는 main.tex를 가지고 있습니다.

\documentclass[a4paper]{article}

\usepackage[store-env=flashcards,store-cmd=flashcards]{scontents}
\setupsc{print-env=false}
\usepackage{forloop}

\newcommand{\flash}[2]{%
\Scontents{#1}\Scontents{#2}%
Side 1: #1

Side 2: #2
}

\begin{document}

\flash{A}{B}
\flash{C}{D}

\clearpage
\include{flashcards}

\end{document}

그리고 flashcards.tex

\documentclass[frontgrid]{flacards}

\begin{document}

\newcounter{ct}
\newcounter{ct2}
\newcounter{maxct}
\setcounter{maxct}{\countsc{flashcards}}
\forloop[2]{ct}{1}{\value{ct} < \value{maxct}}%
{%
  \setcounter{ct2}{\value{ct}}
  \addtocounter{ct2}{1}
  \card{\getstored[\value{ct}]{flashcards}}{\getstored[\value{ct2}]{flashcards}}
}

\end{document}

답변1

플래카드 클래스를 패키지로 변환하고 형상을 약간 조정하여 이 문제를 해결할 수 있었습니다. 따라서 이 솔루션은 A4 용지에만 적용됩니다. 결과적으로 \flash{A}{B}내 문서에 추가하고 얻을 수 있습니다.

인라인으로 나타나는 플래시카드

인라인 및

부록에 나오는 플래시 카드

부록에서.

서문에 다음을 추가하세요.

\documentclass[notoc,nols,a4paper]{tufte-book}
...
\usepackage[store-env=flashcards,store-cmd=flashcards]{scontents}
\setupsc{print-env=false}
\usepackage{forloop}

\newcommand{\flash}[2]{%
\Scontents{#1}\Scontents{#2}%
\noindent%
\begin{minipage}{80mm}
  \begin{flashfront}
    #1
  \end{flashfront}
\end{minipage}% This must go next to `\end{minipage}`
\begin{minipage}{80mm}
  \begin{flashback}
    #2
  \end{flashback}
\end{minipage}
}

\usepackage{tikz}
\usepackage[framemethod=TikZ]{mdframed}

\newenvironment{flashfront}[1][]{%
\ifstrempty{#1}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=blue!20]
{\strut Front};}}
}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=blue!20]
{\strut Front:~#1};}}%
}%
\mdfsetup{innertopmargin=10pt,linecolor=blue!20,%
linewidth=2pt,topline=true,%
frametitleaboveskip=\dimexpr-\ht\strutbox\relax
}
\begin{mdframed}[]\relax%
\sloppy
}{\end{mdframed}}

\newenvironment{flashback}[1][]{%
\ifstrempty{#1}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=red!20]
{\strut Back};}}
}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=red!20]
{\strut Back:~#1};}}%
}%
\mdfsetup{innertopmargin=10pt,linecolor=red!20,%
linewidth=2pt,topline=true,%
frametitleaboveskip=\dimexpr-\ht\strutbox\relax
}
\begin{mdframed}[]\relax%
\sloppy
}{\end{mdframed}}

그런 다음 플래시카드를 표시할 위치

\chapter*{Flashcards}
\newcounter{ct}
\newcounter{ct2}
\newcounter{maxct}
\setcounter{maxct}{\countsc{flashcards}}
\forloop[2]{ct}{1}{\value{ct} < \value{maxct}}%
{%
  \setcounter{ct2}{\value{ct}}
  \addtocounter{ct2}{1}
  \card{\getstored[\value{ct}]{flashcards}}{\getstored[\value{ct2}]{flashcards}}
}
\newgeometry{textwidth=20cm,noheadfoot, margin=1cm, outer=1cm, inner=1cm}
\cleardoublepage
\pagestyle{empty}
\box\front\newpage\box\back
\restoregeometry

라는 파일을 만듭니다.myflash.sty


\def\fc@frontgrid{true}
\def\fc@backgrid{true}
\def\textwidthh{190mm}

%TODO: margin managment
%\RequirePackage[noheadfoot, margin=1cm, outer=1cm, inner=1cm]{geometry}

% TODO: replace
\newcommand*{\fc@strippt}[1]{%
    \strip@pt#1}%

\newcounter{cardno}\setcounter{cardno}{0}
\newcount\cardperpage
\newdimen\cardwidth
\newdimen\cardheight

\newcommand{\fc@boxcontent}[2]{%
\parindent=0pt%
{\cardbox{#1}{#2}}%
}

\newcommand{\cardbox}[2]{%
\vbox{%
\vskip\fboxsep%
\hbox{%
\hskip\fboxsep%
{\advance\cardheight by -2\fboxsep
\vbox to \cardheight {%
\hsize=\cardwidth\advance\hsize by -2\fboxsep%
{\cardinnerbox{#1}{#2}}}%
}\hskip\fboxsep}}%
}

\newcommand{\cardinnerbox}[2]{%
 \sloppy%
 %\smash%
 {%
 \makebox[0pt][l]{\parbox[t]{\cardwidth}{\raggedright\csname #1lhead\endcsname}}\hfill%
 \makebox[0pt][c]{\parbox[t]{\cardwidth}{\centering\csname #1chead\endcsname}}\hfill%
 \makebox[0pt][r]{\parbox[t]{\cardwidth}{\raggedleft\csname #1rhead\endcsname}}%
 }%
 \vfill%
 {\cardtext{#1}{#2}}
 \vfill%
 %\smash%
 {%
 \makebox[0pt][l]{\parbox[b]{\cardwidth}{\raggedright\csname #1lfoot\endcsname}}\hfill%
 \makebox[0pt][c]{\parbox[b]{\cardwidth}{\centering\csname #1cfoot\endcsname}}\hfill%
 \makebox[0pt][r]{\parbox[b]{\cardwidth}{\raggedleft\csname #1rfoot\endcsname}}%
 }%
}

\newcommand{\cardtext}[2]{%
\centering{\csname cardtextstyle#1\endcsname #2\\}%
}

\newcommand{\cardtextstylef}{%
\itshape}

\newcommand{\cardtextstyleb}{%
\itshape}

%% front
\newsavebox\front
\setbox\front=\vbox{}
% layout
\newcommand{\flhead}{}\newcommand{\fchead}{}\newcommand{\frhead}{}
\newcommand{\flfoot}{}\newcommand{\fcfoot}{}\newcommand{\frfoot}{}

%% back
\newsavebox\back
\setbox\back=\vbox{}
% layout 
\newcommand{\blhead}{}\newcommand{\bchead}{}\newcommand{\brhead}{}
\newcommand{\blfoot}{}\newcommand{\bcfoot}{}\newcommand{\brfoot}{}

\renewcommand{\frfoot}{\footnotesize \thecardno}
\renewcommand{\brfoot}{\footnotesize \thecardno}

\newcommand{\pagesetup}[2]{%
\def\rowsperpage{#2}\relax%
\def\colsperpage{#1}\relax%
\cardwidth=\textwidthh\relax%
\cardheight=\textheight\relax%
\divide\cardwidth by \colsperpage%
\divide\cardheight by \rowsperpage%
\cardperpage=\colsperpage\relax%
\multiply\cardperpage by \rowsperpage\relax%
}

\newcommand{\card}[2]{%
\@tempcnta=-\thecardno\divide\@tempcnta by \cardperpage\multiply\@tempcnta by \cardperpage\advance\@tempcnta by \thecardno\relax%
\@tempcntb=\@tempcnta%
\count@=\@tempcnta\relax%
\divide\count@ by \colsperpage\relax%
\@tempcnta=\count@\relax%
\multiply\count@ by \colsperpage\relax%
\advance\@tempcntb by -\count@\relax%
\stepcounter{cardno}%
\unitlength=1pt%
\advance\@tempcnta by 1\relax%
\@tempdima=\cardheight\relax%
\@tempdimb=\cardwidth\relax%
\advance\@tempdima by \fboxrule\relax%
\advance\@tempdimb by \fboxrule\relax%
\multiply\@tempdima by \@tempcnta\relax%
\multiply\@tempdimb by \@tempcntb\relax%
\advance\@tempdima by -\baselineskip\relax%
\setbox\front=\vbox{\unvbox\front%
\noindent\begin{picture}(0,0)%
\put(\fc@strippt\@tempdimb,-\fc@strippt\@tempdima){%
\ifdefined\fc@frontgrid\framebox(\fc@strippt\cardwidth,\fc@strippt\cardheight)[t]{\fc@boxcontent{f}{#1}}
\else\makebox(\fc@strippt\cardwidth,\fc@strippt\cardheight)[t]{\fc@boxcontent{f}{#1}}%
\fi
}%
\end{picture}%
}%
\setbox\back=\vbox{\unvbox\back%
\noindent\begin{picture}(0,0)%
\multiply\@tempdimb by -1\relax%
\advance\@tempdimb by \textwidthh\relax%
\advance\@tempdimb by -\cardwidth\relax%
\put(\fc@strippt\@tempdimb,-\fc@strippt\@tempdima){%
\ifdefined\fc@backgrid\framebox(\fc@strippt\cardwidth,\fc@strippt\cardheight)[t]{\fc@boxcontent{b}{#2}}%
\else\makebox(\fc@strippt\cardwidth,\fc@strippt\cardheight)[t]{\fc@boxcontent{b}{#2}}%
\fi%
}%
\end{picture}%
}%
\count@=\thecardno\divide\count@ by \cardperpage\multiply\count@ by \cardperpage\advance\count@ by -\thecardno\relax%
\ifnum \count@=0\relax%
\noindent\box\front\newpage\box\back\newpage%
\else\fi
}

관련 정보