在表达式中从 textwidth 中减去 leftskip

在表达式中从 textwidth 中减去 leftskip

如果我做:\includegraphics[width=\textwidth-\leftskip]{image.png}

我得到的图片大小与我减去其值 483pt-60pt = 423pt 时得到的图片大小并不相同。

但如果我这么做:\includegraphics[width=\textwidth-10em]{image.png}

图像变小了...

我怎样才能\leftskip\textwidth图形表达式的宽度前言中减去?

以下是我的一些复杂的 MWE:

    \documentclass{article}
    \usepackage[
    left=20mm,
    right=20mm,
    top=20mm,
    bottom=18mm,
    footskip=2em,
    headheight=2em,
    headsep=0.8em
    ]{geometry}
    \usepackage[utf8]{inputenc}
    \usepackage{graphicx}   
    \usepackage{lipsum} 
    \leftskip=60pt                      
    \setlength{\parskip}{\baselineskip}      
    \setlength{\parindent}{0pt}             
      \setlength{\parskip}{0pt}
      \setlength{\textwidth}{483pt}         
    \usepackage{titlesec}
    \titleformat{\section}
       {\normalfont\fontsize{17pt}{18pt}\selectfont\scshape}{\thesection}{15mm}{}
    \titleformat{\subsection}
       {\normalfont\fontsize{16pt}{17pt}\selectfont\scshape}{\thesubsection}{10mm}{}
    \titleformat{\subsubsection}
       {\normalfont\fontsize{15pt}{16pt}\selectfont\scshape}{\thesubsubsection}{10mm}{}
    \titleformat{\paragraph}
       {\normalfont\fontsize{14pt}{15pt}\selectfont\scshape}{\theparagraph}{10mm}{} 
    \titleformat{\subparagraph}
       {\normalfont\fontsize{13pt}{14pt}\selectfont\scshape}{\thesubparagraph}{10mm}{}
    \begin{document}
    \section{one}
    \lipsum[1]
    \subsection{subone}
    \lipsum[2]
      \begin{figure}[!ht]
        \begin{flushright}
          \includegraphics[width=\textwidth]{example-image}
        \end{flushright}
      \end{figure}
    \section{two}
    \lipsum[3]
    \subsection{subtwo}
      \begin{figure}[!ht]
        \begin{flushright}
          \includegraphics[width=\dimexpr\textwidth-\leftskip\relax]{example-image}
        \end{flushright}
      \end{figure}
    \lipsum[4]
    \end{document} 

我在找什么

答案1

表达式\dimexpr\textwidth-\leftskip有效,但是\leftskip内部的flushright行为0.0pt plus 1.0fil0pt在 a 中的行为相同\dimexpr,因此值为\textwidth

在此处输入图片描述

  \documentclass{article}
    \usepackage[
    left=20mm,
    right=20mm,
    top=20mm,
    bottom=18mm,
    footskip=2em,
    headheight=2em,
    headsep=0.8em
    ]{geometry}
    \usepackage[utf8]{inputenc}
    \usepackage{graphicx}   
    \usepackage{lipsum} 

    \setlength{\parskip}{\baselineskip} % this is not used     
    \setlength{\parindent}{0pt}             
      \setlength{\parskip}{0pt}% really?
      \setlength{\textwidth}{483pt}

    \addtolength\oddsidemargin{60pt}       
    \usepackage{titlesec}
    \titleformat{\section}
       {\normalfont\fontsize{17pt}{18pt}\selectfont\scshape}{\hspace*{-\oddsidemargin}\rlap{\thesection}}{\oddsidemargin}{}
    \titleformat{\subsection}
       {\normalfont\fontsize{16pt}{17pt}\selectfont\scshape}{\hspace*{-\oddsidemargin}\rlap{\thesubsection}}{\oddsidemargin}{}
    \titleformat{\subsubsection}
       {\normalfont\fontsize{15pt}{16pt}\selectfont\scshape}{\thesubsubsection}{10mm}{}
    \titleformat{\paragraph}
       {\normalfont\fontsize{14pt}{15pt}\selectfont\scshape}{\theparagraph}{10mm}{} 
    \titleformat{\subparagraph}
       {\normalfont\fontsize{13pt}{14pt}\selectfont\scshape}{\thesubparagraph}{10mm}{}
    \begin{document}
    \section{one}
    \lipsum[1]
    \subsection{subone}
    \lipsum[2]


          \includegraphics[width=\linewidth]{example-image}

    \section{two}
    \lipsum[3]
    \subsection{subtwo}
          \includegraphics[width=\linewidth]{example-image}

    \lipsum[4]
    \end{document} 

相关内容