Modifica stile elementi a margine della classe tufte

  • Creatore
    Topic
  • #104910
    Up
    0
    Down
    ::


    Buonasera a tutti, sto cercando di far funzionare un versione del comando \caption modificata ma non riesco a farlo accettare all’ambiente margintable, mentre l’ambiente table lo accetta tranquillamente. Il problema penso che sia la macro \my@caption@type che anche se definita come globale tramite \gdef non viene comunque vista al momento della chiamata…

    Ecco un MWE che riproduce il problema:

    `\documentclass[nofonts]{tufte-handout}

    \usepackage{booktabs}

    \makeatletter

    \long\def\@caption#1[#2]#3{%
    \par%
    \addcontentsline{\csname ext@#1\endcsname}{#1}%
    % {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
    {\protect\numberline{\textsc{\my@caption@type}}{\ignorespaces #2}}%
    \begingroup
    \@parboxrestore
    \if@minipage
    \@setminipage
    \fi
    \@tufte@caption@font\@tufte@caption@justification
    \noindent\textsc{\my@caption@type} \ignorespaces#3\par
    %\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
    \endgroup
    }

    \long\def\@tufte@caption[#1][#2]#3#4{%
    \gdef\my@caption@type{#3}%
    \ifthenelse{\isempty{#1}}%
    {\gdef\@tufte@stored@shortcaption{#4}}%
    {\gdef\@tufte@stored@shortcaption{#1}}%
    \gsetlength{\@tufte@caption@vertical@offset}{-#2}%
    \gdef\@tufte@stored@caption{#4}%
    }

    \renewcommand*{\@tufte@lof@line}[2]{%
    % #1 is the figure/table number and its caption text
    % #2 is the page number on which the figure/table appears
    \leftskip 0.0em
    \rightskip 0em
    \parfillskip 0em plus 1fil
    \parindent 0.0em
    \@afterindenttrue
    \interlinepenalty\@M
    \leavevmode
    % Increase space for the “number”
    \settowidth{\@tempdima}{\textsc{Fonts}\enspace}% largest term
    \advance\leftskip\@tempdima
    \null\nobreak\hskip -\leftskip
    {#1}\nobreak\qquad\nobreak#2%
    \par%
    }%

    \makeatother

    \begin{document}

    \begin{margintable}[-25pt]
    \caption{Esempio}{Conversione dal sistema numerico decimale a quello binario $115_{(10)}\rightarrow 1110011_{(2)}$.}
    \begin{flushleft}
    \begin{tabular}{cccc}
    \toprule
    $N_{(10)}$ & $r$ & \textsc{Resto} & \textsc{Cifra}\\
    \midrule
    115 & 2 & 1 & 0\\
    57 & 2 & 1 & 1\\
    28 & 2 & 0 & 2\\
    14 & 2 & 0 & 3\\
    7 & 2 & 1 & 4\\
    3 & 2 & 1 & 5\\
    1 & 2 & 1 & 6\\
    0 & & & \\
    \bottomrule
    \end{tabular}
    \end{flushleft}
    \end{margintable}

    \end{document}`

    Inoltre vorrei chiedere se esiste un modo per far “agganciare” a LaTeX un data linea di testo da usare come riferimento per il posizionamento degli elementi a margine, in modo che ci sia un allineamento automatico e perfetto alla riga di testo a cui si riferisce l’elemento a margine, nota, immagine, tabella ecc. Grazie.

  • Devi essere connesso per rispondere a questo topic.

Go to top