0

Currently, I achieve the equal sizing of 4 different figures by means of \includegraphics[width=0.197\linewidth]{example-image-a}.

enter image description here

However, the 0.197 is hard-coded and therefore not elegant.

Is there a more dynamic way of achieving the desired output?

Please see my MWE:

\documentclass[10pt, a4paper]{ltjbook}
\usepackage{luatexja}
\usepackage{CJKutf8}
\usepackage[left=1.9cm,right=1.9cm,bottom=1.5cm,top=1.5cm]{geometry}
\usepackage[table]{xcolor}
\usepackage{amsmath}
\usepackage{ruby}
\usepackage{tikz,pgfplots,makecell,array,aurical,longtable,booktabs,multicol,multirow}
\usetikzlibrary{patterns, mindmap, positioning, automata}
\usepackage{environ}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{textcomp}
\usepackage{hhline}
\usepackage{textcomp}
\usepackage{wasysym}
\usepackage{multicol}
\usepackage{microtype}
\usepackage[table]{xcolor}
\usepackage{ulem}
\usepackage[none]{hyphenat}
\usepackage{xparse}
\usepackage{imakeidx}
\usepackage{setspace}

%>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
\newsavebox\ltmcbox
% The following command inhibits a column break after a group letter in the index
% It also swallows the following \\, because the \\ is here before the \nopagebreak.
\newcommand{\dontbreak}[1]{\\\nopagebreak} % Swallow the following \\
\makeindex[name=gen, columns=4, title={漢字 Index}, intoc, columnseprule, options=-s general.ist]
\newcommand{\gindex}[2]{\index[gen]{#1 & #2}}
%<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


%>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
\newcommand\strokesection{} % to make sure we can use this command
\def\strokesection#1\par#2\par{\vspace{5pt}\par
    \parbox[t]{\linewidth}{{#1}\\#2\strut}\par
}

\makeatletter
\patchcmd\LT@array{\tabskip\z@}{\tabskip\fill}{\typeout{OK}}{\typeout{BAD}}
\setlength\LTleft{0pt}\setlength\LTright{0pt}
\makeatletter

\makeindex[name=stroke, columns=4, title={漢字 by Stroke Count}, intoc, columnseprule, options=-s strokes.ist]
\newcommand{\strokeshead}[1]{%
    \rmfamily\textbf{#1 Stroke\ifnum#1>1 s\fi}%
}
\newcommand{\strindex}[2]{\index[stroke]{#1@\strokeshead{#1}!#2}}
%<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

\usepackage{hyperref}
\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black
}

\newcolumntype{A}{>{\centering\let\newline\\\arraybackslash}X}
\newcolumntype{B}{>{\raggedright\let\newline\\\arraybackslash}X}

\newcommand{\specialc}[2][c]{\setstretch{0.87}\begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}
\newcommand{\speciall}[2][c]{\begin{tabular}[#1]{@{}l@{}}#2\end{tabular}}
\newcommand{\specialr}[2][c]{\begin{tabular}[#1]{@{}r@{}}#2\end{tabular}}


\usepackage{graphicx}

\pgfplotsset{compat=newest,compat/show suggested version=false}
\usetikzlibrary{pgfplots.groupplots,matrix,positioning,fit,calc,shapes,patterns,automata,plotmarks}

\setlength{\parindent}{0cm}

\renewcommand{\tabularxcolumn}[1]{>{\small}m{#1}}

\newcommand{\rye}[2]{\multicolumn{#1}{|l@{}|}{\renewcommand{\arraystretch}{1.2}\begin{tabularx}{0.95\columnwidth}{@{}B@{}}#2\end{tabularx}}\\\hline}

\usepackage{tocloft}
\newcommand{\listofkanji}{List of Kanji}
\newlistof{glyph}{lok}{\listofkanji}
\NewEnviron{glyph}[2]% environment name
{   \refstepcounter{glyph}%
    \addcontentsline{lok}{glyph}{\protect\numberline{\theglyph}{\;}{\;}#1}
    \begin{tabularx}{\columnwidth}{@{}|A|A|A|A|@{}}
        \hhline{|----|}
        \multicolumn{4}{|B|}{\cellcolor{black}{\color{white}\textbf{\large{漢字{\,}\theglyph{:}\;{#1}}}}} \\\hline %row comp
        \hhline{|----|}
        \multicolumn{1}{|c}{\includegraphics[width=0.197\linewidth]{example-image-a}} & \multicolumn{1}{|c}{\includegraphics[width=0.197\linewidth]{example-image-a}} &
        \multicolumn{1}{|c}{\includegraphics[width=0.197\linewidth]{example-image-a}} &
        \multicolumn{1}{|c|}{\includegraphics[width=0.197\linewidth]{example-image-a}}\\\hline
        \multicolumn{4}{|B|}{\renewcommand{\arraystretch}{1.2}
            \begin{tabularx}{0.95\columnwidth}{@{}B@{}}\BODY\end{tabularx}}\\\hline
    \end{tabularx}\renewcommand{\arraystretch}{1}
}

\begin{document}
\begin{multicols}{2}
\begin{glyph}{Anew (更)}{anew}\label{glyph:anew}
The idea of \textit{doing things anew}, be it through \textsuperscript{[1]}\textit{revision}, \textsuperscript{[2]}\textit{reform} or \textsuperscript{[3]}\textit{renewal}, amongst others.\\\hline
A secondary meaning has to do with \textit{staying up late}, or \textit{the day growing late}.
\end{glyph}
\end{multicols}

\end{document}
2
  • You can start with replacing \multicolumn{1}{|c}{\includegraphics[width=0.197\linewidth]{example-image-a}} by \includegraphics[width=\linewidth]{example-image-a}. Since your A type columns are parboxes, they reset \linewidth appropriately. Commented Jan 11, 2022 at 11:23
  • @SergeiGolovan I have tried your suggestion, but it gives undesired output... Commented Jan 12, 2022 at 8:00

1 Answer 1

2

Added a similar (simpler) environment glyphx to remove the annoying 0.197.

b

Only relevant packets were kept in the preamble.

\documentclass[10pt, a4paper]{ltjbook}
\usepackage{luatexja}
\usepackage{CJKutf8}

\usepackage[left=1.9cm,right=1.9cm,bottom=1.5cm,top=1.5cm]{geometry}
\usepackage[table]{xcolor}
\usepackage{multicol}
\usepackage{environ}
\usepackage{tabularx}
\usepackage{hhline}
\usepackage{graphicx}

\newcolumntype{A}{>{\centering\let\newline\\\arraybackslash}X}
\newcolumntype{B}{>{\small\raggedright\let\newline\\\arraybackslash}X}  

\setlength{\parindent}{0cm}
\renewcommand{\tabularxcolumn}[1]{>{\small\raggedright}m{#1}}   

\usepackage{tocloft}
\newcommand{\listofkanji}{List of Kanji}
\newlistof{glyph}{lok}{\listofkanji}

\NewEnviron{glyph}[2]% environment name
{\refstepcounter{glyph}%
    \addcontentsline{lok}{glyph}{\protect\numberline{\theglyph}{\;}{\;}#1}
    \begin{tabularx}{\columnwidth}{@{}|A|A|A|A|@{}}
        \hhline{|----|}
        \multicolumn{4}{|B|}{\cellcolor{black}{\color{white}\textbf{\large{漢字{\,}\theglyph{:}\;{#1}}}}} \\\hline %row comp
        \hhline{|----|}
        \multicolumn{1}{|c}{\includegraphics[width=0.197\linewidth]{example-image-a}} & \multicolumn{1}{|c}{\includegraphics[width=0.197\linewidth]{example-image-a}} &
        \multicolumn{1}{|c}{\includegraphics[width=0.197\linewidth]{example-image-a}} &
        \multicolumn{1}{|c|}{\includegraphics[width=0.197\linewidth]{example-image-a}}\\\hline
        \multicolumn{4}{|B|}{\renewcommand{\arraystretch}{1.2}
            \begin{tabularx}{0.95\columnwidth}{@{}B@{}}\BODY\end{tabularx}}\\\hline
    \end{tabularx}\renewcommand{\arraystretch}{1}
}

\NewEnviron{glyphx}[2]% added <<<<<<<<<<<<<<<<<<<<<
{   \refstepcounter{glyph}%
    \addcontentsline{lok}{glyph}{\protect\numberline{\theglyph}{\;}{\;}#1}
    \begin{tabularx}{\columnwidth}{|A|A|A|A|}
        \multicolumn{4}{|l|}{\cellcolor{black}{\color{white}\textbf{\large{漢字{\,}\theglyph{:}\;{#1}}}}} \\\hline %row comp  
        \includegraphics[width=\linewidth]{example-image-a} & 
        \includegraphics[width=\linewidth]{example-image-a} &
        \includegraphics[width=\linewidth]{example-image-a} &
        \includegraphics[width=\linewidth]{example-image-a}\\\hline
        \multicolumn{4}{|l|}{\renewcommand{\arraystretch}{1.2}
        \begin{tabularx}{0.9\columnwidth}{@{}B@{}}\BODY\end{tabularx}}\\\hline
    \end{tabularx}\renewcommand{\arraystretch}{1}
}


\begin{document}
    \begin{multicols}{2}
        \begin{glyph}{Anew (更)}{anew}\label{glyph:anew1}
            The idea of \textit{doing things anew}, be it through \textsuperscript{[1]}\textit{revision}, \textsuperscript{[2]}\textit{reform} or \textsuperscript{[3]}\textit{renewal}, amongst others.\\\hline
            A secondary meaning has to do with \textit{staying up late}, or \textit{the day growing late}.
        \end{glyph}
    \end{multicols}\bigskip

    \begin{multicols}{2}
    \begin{glyphx}{Anew (更)}{anew}\label{glyph:anew2}
        The idea of \textit{doing things anew}, be it through \textsuperscript{[1]}\textit{revision}, \textsuperscript{[2]}\textit{reform} or \textsuperscript{[3]}\textit{renewal}, amongst others.\\ \hline
    A secondary meaning   has to do with \textit{staying up late}, or \textit{the day growing late.} 
    \end{glyphx}
\end{multicols}

    
\end{document}
1
  • Thank you @Simon. Is there maybe a way to save the {0.95\columnwidth}? I.e., to have a slightly wider column width for the text beneath the 4 pictures? Commented Jan 14, 2022 at 18:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .